From 0b3db9af23bd8caaf2b06092ac43539b01645bda Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Mon, 14 Nov 2016 22:49:19 +0000 Subject: [PATCH] Remove allocation of list that is not neccesary --- src/Avalonia.Controls/ItemsControl.cs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/Avalonia.Controls/ItemsControl.cs b/src/Avalonia.Controls/ItemsControl.cs index ca1858cc65..67f726d056 100644 --- a/src/Avalonia.Controls/ItemsControl.cs +++ b/src/Avalonia.Controls/ItemsControl.cs @@ -260,8 +260,6 @@ namespace Avalonia.Controls /// The details of the containers. protected virtual void OnContainersDematerialized(ItemContainerEventArgs e) { - var toRemove = new List(); - foreach (var container in e.Containers) { // 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) { - toRemove.Add(containerControl.Child); ((ISetLogicalParent)containerControl).SetParent(null); + LogicalChildren.Remove(containerControl.Child); } } else { - toRemove.Add(container.ContainerControl); + LogicalChildren.Remove(container.ContainerControl); } } } - - LogicalChildren.RemoveAll(toRemove); } ///