Browse Source

Remove allocation of list that is not neccesary

pull/799/head
Dan Walmsley 10 years ago
parent
commit
0b3db9af23
  1. 8
      src/Avalonia.Controls/ItemsControl.cs

8
src/Avalonia.Controls/ItemsControl.cs

@ -260,8 +260,6 @@ namespace Avalonia.Controls
/// <param name="e">The details of the containers.</param> /// <param name="e">The details of the containers.</param>
protected virtual void OnContainersDematerialized(ItemContainerEventArgs e) protected virtual void OnContainersDematerialized(ItemContainerEventArgs e)
{ {
var toRemove = new List<ILogical>();
foreach (var container in e.Containers) foreach (var container in e.Containers)
{ {
// If the item is its own container, then it will be removed from the logical tree // If the item is its own container, then it will be removed from the logical tree
@ -274,18 +272,16 @@ namespace Avalonia.Controls
if (containerControl != null) if (containerControl != null)
{ {
toRemove.Add(containerControl.Child);
((ISetLogicalParent)containerControl).SetParent(null); ((ISetLogicalParent)containerControl).SetParent(null);
LogicalChildren.Remove(containerControl.Child);
} }
} }
else else
{ {
toRemove.Add(container.ContainerControl); LogicalChildren.Remove(container.ContainerControl);
} }
} }
} }
LogicalChildren.RemoveAll(toRemove);
} }
/// <summary> /// <summary>

Loading…
Cancel
Save