-
Notifications
You must be signed in to change notification settings - Fork 747
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf: Improve name to DependencyProperty lookup
- Loading branch information
1 parent
292522c
commit 4bce59b
Showing
2 changed files
with
56 additions
and
1 deletion.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
src/Uno.UI/UI/Xaml/DependencyProperty.Dictionary.NameToProperty.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 |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#nullable enable | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using Windows.UI.Xaml; | ||
using Uno.Extensions; | ||
using System.Diagnostics; | ||
using System.Runtime.CompilerServices; | ||
using Uno; | ||
using System.Threading; | ||
using Uno.Collections; | ||
|
||
#if XAMARIN_ANDROID | ||
using _View = Android.Views.View; | ||
#elif XAMARIN_IOS_UNIFIED | ||
using _View = UIKit.UIView; | ||
#else | ||
using _View = Windows.UI.Xaml.UIElement; | ||
#endif | ||
|
||
namespace Windows.UI.Xaml | ||
{ | ||
public sealed partial class DependencyProperty | ||
{ | ||
private class NameToPropertyDictionary | ||
{ | ||
private readonly HashtableEx _entries = new HashtableEx(PropertyCacheEntry.DefaultComparer); | ||
|
||
internal bool TryGetValue(PropertyCacheEntry key, out DependencyProperty? result) | ||
{ | ||
if (_entries.TryGetValue(key, out var value)) | ||
{ | ||
result = (DependencyProperty)value!; | ||
|
||
return true; | ||
} | ||
|
||
result = null; | ||
return false; | ||
} | ||
|
||
internal void Add(PropertyCacheEntry key, DependencyProperty dependencyProperty) | ||
=> _entries.Add(key, dependencyProperty); | ||
|
||
internal void Remove(PropertyCacheEntry propertyCacheEntry) | ||
=> _entries.Remove(propertyCacheEntry); | ||
|
||
internal int Count => _entries.Count; | ||
|
||
internal void Clear() => _entries.Clear(); | ||
} | ||
} | ||
} |
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