forked from unoplatform/uno
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request unoplatform#15538 from unoplatform/Youssef1313/anc…
…estors-dict perf: Make AncestorsDictionary a struct
- Loading branch information
Showing
1 changed file
with
26 additions
and
40 deletions.
There are no files selected for viewing
66 changes: 26 additions & 40 deletions
66
src/Uno.UI/UI/Xaml/DependencyObjectStore.AncestorsDictionary.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,41 @@ | ||
#nullable enable | ||
|
||
using System; | ||
using Uno.UI.DataBinding; | ||
using System.Collections.Generic; | ||
using Uno.Extensions; | ||
using Uno.Foundation.Logging; | ||
using Uno.Diagnostics.Eventing; | ||
using Uno.Disposables; | ||
using System.Linq; | ||
using System.Threading; | ||
using Uno.Collections; | ||
using System.Runtime.CompilerServices; | ||
using System.Diagnostics; | ||
using Microsoft.UI.Xaml.Data; | ||
using Uno.UI; | ||
using System.Collections; | ||
|
||
#if __ANDROID__ | ||
using View = Android.Views.View; | ||
#elif __IOS__ | ||
using View = UIKit.UIView; | ||
#endif | ||
|
||
namespace Microsoft.UI.Xaml | ||
|
||
namespace Microsoft.UI.Xaml; | ||
|
||
public partial class DependencyObjectStore : IDisposable | ||
{ | ||
public partial class DependencyObjectStore : IDisposable | ||
private readonly struct AncestorsDictionary | ||
{ | ||
private class AncestorsDictionary | ||
private readonly HashtableEx _entries = new HashtableEx(); | ||
|
||
// Constructor to avoid: | ||
// error CS8983: A 'struct' with field initializers must include an explicitly declared constructor. | ||
public AncestorsDictionary() | ||
{ | ||
private readonly HashtableEx _entries = new HashtableEx(); | ||
} | ||
|
||
internal bool TryGetValue(object key, out bool isAncestor) | ||
internal bool TryGetValue(object key, out bool isAncestor) | ||
{ | ||
if (_entries.TryGetValue(key, out var value)) | ||
{ | ||
if (_entries.TryGetValue(key, out var value)) | ||
{ | ||
isAncestor = (bool)value!; | ||
return true; | ||
} | ||
|
||
isAncestor = false; | ||
return false; | ||
isAncestor = (bool)value!; | ||
return true; | ||
} | ||
|
||
internal void Set(object key, bool isAncestor) | ||
=> _entries[key] = isAncestor; | ||
isAncestor = false; | ||
return false; | ||
} | ||
|
||
internal void Set(object key, bool isAncestor) | ||
=> _entries[key] = isAncestor; | ||
|
||
internal void Clear() | ||
=> _entries.Clear(); | ||
internal void Clear() | ||
=> _entries.Clear(); | ||
|
||
internal void Dispose() | ||
=> _entries.Dispose(); | ||
} | ||
internal void Dispose() | ||
=> _entries.Dispose(); | ||
} | ||
} |