Skip to content

Commit

Permalink
perf: Don't create attached stores on bindable propagation
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromelaban committed Apr 9, 2021
1 parent 3b40a9c commit ef17b62
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/Uno.UI/UI/Xaml/DependencyObjectStore.Binder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -123,9 +128,9 @@ void SetInherited(IDependencyObjectStoreProvider provider)
continue;
}

if (child is IDependencyObjectStoreProvider provider)
if (childAsStoreProvider != null)
{
SetInherited(provider);
SetInherited(childAsStoreProvider);
}
else
{
Expand Down

0 comments on commit ef17b62

Please sign in to comment.