From 82203bedae02c8a1e6c4a70a840a7083611b0e5e Mon Sep 17 00:00:00 2001 From: Youssef Victor Date: Sat, 21 Oct 2023 08:28:43 +0300 Subject: [PATCH] perf: Optimize `GetCurrentHighestValuePrecedence` to not force create property details --- src/Uno.UI/UI/Xaml/DependencyObjectStore.cs | 4 +++- src/Uno.UI/UI/Xaml/DependencyPropertyDetailsCollection.cs | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Uno.UI/UI/Xaml/DependencyObjectStore.cs b/src/Uno.UI/UI/Xaml/DependencyObjectStore.cs index 490a628c78b7..bf2d88ad69fd 100644 --- a/src/Uno.UI/UI/Xaml/DependencyObjectStore.cs +++ b/src/Uno.UI/UI/Xaml/DependencyObjectStore.cs @@ -309,7 +309,9 @@ internal DependencyPropertyValuePrecedences GetCurrentHighestValuePrecedence(Dep /// 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; } /// diff --git a/src/Uno.UI/UI/Xaml/DependencyPropertyDetailsCollection.cs b/src/Uno.UI/UI/Xaml/DependencyPropertyDetailsCollection.cs index 7e7c27db2a39..30bec1711cd4 100644 --- a/src/Uno.UI/UI/Xaml/DependencyPropertyDetailsCollection.cs +++ b/src/Uno.UI/UI/Xaml/DependencyPropertyDetailsCollection.cs @@ -117,8 +117,8 @@ public DependencyPropertyDetails GetPropertyDetails(DependencyProperty property) /// /// A dependency property /// The details of the property if it exists, otherwise null. - 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) {