Tackle the last of the low hanging fruit for memory allocations in the main game loop.

- Avoid calling string.Split twice in SprintFont.Measure.
- Change ActorsInBox method of ActorMap and ScreenMap to avoid allocating and intermediate list. As a bonus this allows the sequence to be lazily consumed. Also avoid LINQ in these methods.
- In FrozenUnderFog.TickRender, the method exits early if no players are visible so the attempt at lazy generation was not needed.
- Unwrap a LINQ Any call in ClassicProductionQueue.Tick.
- Merge some successive Where calls in ProximityCapturable into single predicates.
This commit is contained in:
RoosterDragon
2014-06-21 01:31:19 +01:00
parent a5d765e100
commit 8a60880cf1
6 changed files with 33 additions and 38 deletions

View File

@@ -85,7 +85,8 @@ namespace OpenRA.Graphics
public int2 Measure(string text)
{
return new int2((int)text.Split('\n').Max(s => s.Sum(a => glyphs[Pair.New(a, Color.White)].Advance)), text.Split('\n').Count()*size);
var lines = text.Split('\n');
return new int2((int)Math.Ceiling(lines.Max(s => s.Sum(a => glyphs[Pair.New(a, Color.White)].Advance))), lines.Length * size);
}
Cache<Pair<char,Color>, GlyphInfo> glyphs;