Improved Widget.RemoveChildren performance

Modifying the list potentially several thousand times is really slow, so notify the child elements that they are being removed and then clear the list in one go.
This commit is contained in:
Gustas
2022-08-30 16:12:58 +03:00
committed by abcdefg30
parent 378c447ded
commit 8402d7d476

View File

@@ -524,8 +524,10 @@ namespace OpenRA.Widgets
public virtual void RemoveChildren()
{
while (Children.Count > 0)
RemoveChild(Children[Children.Count - 1]);
foreach (var child in Children)
child?.Removed();
Children.Clear();
}
public virtual void Hidden()