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

@@ -239,7 +239,15 @@ namespace OpenRA.Graphics
return new int2(0, size);
var lines = text.Split('\n');
return new int2((int)Math.Ceiling(lines.Max(lineWidth)), lines.Length * size);
return new int2((int)Math.Ceiling(MaxLineWidth(lines, lineWidth)), lines.Length * size);
}
static float MaxLineWidth(string[] lines, Func<string, float> lineWidth)
{
var maxWidth = 0f;
foreach (var line in lines)
maxWidth = Math.Max(maxWidth, lineWidth(line));
return maxWidth;
}
GlyphInfo CreateGlyph(char c)