Skip to content

Commit

Permalink
perf: Optimize GetCurrentHighestValuePrecedence to not force create…
Browse files Browse the repository at this point in the history
… property details
  • Loading branch information
Youssef1313 committed Oct 21, 2023
1 parent c6a4a93 commit 82203be
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/Uno.UI/UI/Xaml/DependencyObjectStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,9 @@ internal DependencyPropertyValuePrecedences GetCurrentHighestValuePrecedence(Dep
/// <returns></returns>
internal DependencyPropertyValuePrecedences GetCurrentHighestValuePrecedence(DependencyProperty property)
{
return _properties.GetPropertyDetails(property).CurrentHighestValuePrecedence;
// There is no need to force-create property details here.
// If it's not yet created, then simply the precedence is DefaultValue
return _properties.FindPropertyDetails(property)?.CurrentHighestValuePrecedence ?? DependencyPropertyValuePrecedences.DefaultValue;
}

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions src/Uno.UI/UI/Xaml/DependencyPropertyDetailsCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ public DependencyPropertyDetails GetPropertyDetails(DependencyProperty property)
/// </summary>
/// <param name="property">A dependency property</param>
/// <returns>The details of the property if it exists, otherwise null.</returns>
public DependencyPropertyDetails FindPropertyDetails(DependencyProperty property)
=> TryGetPropertyDetails(property, forceCreate: false)!;
public DependencyPropertyDetails? FindPropertyDetails(DependencyProperty property)
=> TryGetPropertyDetails(property, forceCreate: false);

private DependencyPropertyDetails? TryGetPropertyDetails(DependencyProperty property, bool forceCreate)
{
Expand Down

0 comments on commit 82203be

Please sign in to comment.