Widget, avoid copying child list when reverse iterating.
This commit is contained in:
@@ -378,9 +378,10 @@ namespace OpenRA.Widgets
|
|||||||
return null;
|
return null;
|
||||||
|
|
||||||
// Do any of our children specify a cursor?
|
// Do any of our children specify a cursor?
|
||||||
foreach (var child in Children.OfType<Widget>().Reverse())
|
// PERF: Avoid LINQ.
|
||||||
|
for (var i = Children.Count - 1; i >= 0; --i)
|
||||||
{
|
{
|
||||||
var cc = child.GetCursorOuter(pos);
|
var cc = Children[i].GetCursorOuter(pos);
|
||||||
if (cc != null)
|
if (cc != null)
|
||||||
return cc;
|
return cc;
|
||||||
}
|
}
|
||||||
@@ -405,8 +406,9 @@ namespace OpenRA.Widgets
|
|||||||
var oldMouseOver = Ui.MouseOverWidget;
|
var oldMouseOver = Ui.MouseOverWidget;
|
||||||
|
|
||||||
// Send the event to the deepest children first and bubble up if unhandled
|
// Send the event to the deepest children first and bubble up if unhandled
|
||||||
foreach (var child in Children.OfType<Widget>().Reverse())
|
// PERF: Avoid LINQ.
|
||||||
if (child.HandleMouseInputOuter(mi))
|
for (var i = Children.Count - 1; i >= 0; --i)
|
||||||
|
if (Children[i].HandleMouseInputOuter(mi))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (IgnoreChildMouseOver)
|
if (IgnoreChildMouseOver)
|
||||||
@@ -426,8 +428,9 @@ namespace OpenRA.Widgets
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Can any of our children handle this?
|
// Can any of our children handle this?
|
||||||
foreach (var child in Children.OfType<Widget>().Reverse())
|
// PERF: Avoid LINQ.
|
||||||
if (child.HandleKeyPressOuter(e))
|
for (var i = Children.Count - 1; i >= 0; --i)
|
||||||
|
if (Children[i].HandleKeyPressOuter(e))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// Do any widgety behavior
|
// Do any widgety behavior
|
||||||
@@ -444,8 +447,9 @@ namespace OpenRA.Widgets
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Can any of our children handle this?
|
// Can any of our children handle this?
|
||||||
foreach (var child in Children.OfType<Widget>().Reverse())
|
// PERF: Avoid LINQ.
|
||||||
if (child.HandleTextInputOuter(text))
|
for (var i = Children.Count - 1; i >= 0; --i)
|
||||||
|
if (Children[i].HandleTextInputOuter(text))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// Do any widgety behavior (enter text etc)
|
// Do any widgety behavior (enter text etc)
|
||||||
@@ -531,8 +535,9 @@ namespace OpenRA.Widgets
|
|||||||
ForceYieldKeyboardFocus();
|
ForceYieldKeyboardFocus();
|
||||||
ForceYieldMouseFocus();
|
ForceYieldMouseFocus();
|
||||||
|
|
||||||
foreach (var c in Children.OfType<Widget>().Reverse())
|
// PERF: Avoid LINQ.
|
||||||
c.Hidden();
|
for (var i = Children.Count - 1; i >= 0; --i)
|
||||||
|
Children[i].Hidden();
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void Removed()
|
public virtual void Removed()
|
||||||
@@ -542,8 +547,9 @@ namespace OpenRA.Widgets
|
|||||||
ForceYieldKeyboardFocus();
|
ForceYieldKeyboardFocus();
|
||||||
ForceYieldMouseFocus();
|
ForceYieldMouseFocus();
|
||||||
|
|
||||||
foreach (var c in Children.OfType<Widget>().Reverse())
|
// PERF: Avoid LINQ.
|
||||||
c.Removed();
|
for (var i = Children.Count - 1; i >= 0; --i)
|
||||||
|
Children[i].Removed();
|
||||||
|
|
||||||
if (LogicObjects != null)
|
if (LogicObjects != null)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user