From ef17b628eb79b382bc9dc755802adc73c19aeb9d Mon Sep 17 00:00:00 2001 From: Jerome Laban Date: Tue, 6 Apr 2021 09:46:26 -0400 Subject: [PATCH] perf: Don't create attached stores on bindable propagation --- src/Uno.UI/UI/Xaml/DependencyObjectStore.Binder.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Uno.UI/UI/Xaml/DependencyObjectStore.Binder.cs b/src/Uno.UI/UI/Xaml/DependencyObjectStore.Binder.cs index 40c42e6497e0..6b420e446dee 100644 --- a/src/Uno.UI/UI/Xaml/DependencyObjectStore.Binder.cs +++ b/src/Uno.UI/UI/Xaml/DependencyObjectStore.Binder.cs @@ -110,7 +110,12 @@ void SetInherited(IDependencyObjectStoreProvider provider) for (int i = 0; i < _childrenBindable.Count; i++) { var child = _childrenBindable[i]; - var parent = child?.GetParent(); + + var childAsStoreProvider = child as IDependencyObjectStoreProvider; + + // Get the parent if the child is a provider, otherwise an + // "attached store" may be created for no good reason. + var parent = childAsStoreProvider?.GetParent(); //Do not propagate value if you are not this child's parent //Covers case where a child may hold a binding to a view higher up the tree @@ -123,9 +128,9 @@ void SetInherited(IDependencyObjectStoreProvider provider) continue; } - if (child is IDependencyObjectStoreProvider provider) + if (childAsStoreProvider != null) { - SetInherited(provider); + SetInherited(childAsStoreProvider); } else {