Merge pull request #5679 from RoosterDragon/main-loop-alloc

Reduce memory allocation in the main loop
This commit is contained in:
Paul Chote
2014-06-26 23:10:56 +12:00
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;