Avoid or reduce LINQ allocations required in various areas.

This commit is contained in:
RoosterDragon
2020-10-11 11:46:39 +01:00
committed by abcdefg30
parent da53d5b776
commit bb116034c7
9 changed files with 31 additions and 24 deletions

View File

@@ -249,7 +249,8 @@ namespace OpenRA.Mods.Common.Widgets
var position = GetTextPosition(text, font, rb);
var hover = Ui.MouseOverWidget == this || Children.Any(c => c == Ui.MouseOverWidget);
// PERF: Avoid LINQ by using Children.Find(...) != null instead of Children.Any(...)
var hover = Ui.MouseOverWidget == this || Children.Find(c => c == Ui.MouseOverWidget) != null;
DrawBackground(rb, disabled, Depressed, hover, highlighted);
if (Contrast)
font.DrawTextWithContrast(text, position + stateOffset,