Skip to content

Commit

Permalink
perf: Use for loops in DependencyObjectCollection
Browse files Browse the repository at this point in the history
Improves WebAssembly performance
  • Loading branch information
jeromelaban committed May 6, 2021
1 parent 88b75d0 commit 0f64934
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Uno.UI/UI/Xaml/DependencyObjectCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,16 @@ private void Initialize()

private void UpdateParent(object parent)
{
foreach (var item in _list)
var actualParent = parent ?? this;

for (var i = 0; i < _list.Count; i++)
{
var item = _list[i];

// Because parent propagation doesn't currently support all cases,
// we can't assume that the DependencyObjectCollection will have a parent.
// To preserve DataContext propagation, we fallback to self if no parent is set.
item.SetParent(parent ?? this);
item.SetParent(actualParent);
}
}

Expand Down

0 comments on commit 0f64934

Please sign in to comment.