remove another 40M/min of boxing junk by specializing the key comparer on SpriteFont's dict

This commit is contained in:
Chris Forbes
2011-03-06 08:59:25 +13:00
parent 8d1a69e8ff
commit 69ea44310b
2 changed files with 11 additions and 2 deletions

View File

@@ -61,6 +61,14 @@ namespace OpenRA.FileFormats
{
return "({0},{1})".F(First, Second);
}
class PairEqualityComparer : IEqualityComparer<Pair<T, U>>
{
public bool Equals(Pair<T, U> x, Pair<T, U> y) { return x == y; }
public int GetHashCode(Pair<T, U> obj) { return obj.GetHashCode(); }
}
public static IEqualityComparer<Pair<T, U>> EqualityComparer { get { return new PairEqualityComparer(); } }
}
public static class Pair

View File

@@ -29,7 +29,8 @@ namespace OpenRA.Graphics
throw new InvalidOperationException("FT_New_Face failed");
FT.FT_Set_Pixel_Sizes(face, 0, (uint)size);
glyphs = new Cache<Pair<char, Color>, GlyphInfo>(CreateGlyph);
glyphs = new Cache<Pair<char, Color>, GlyphInfo>(CreateGlyph,
Pair<char,Color>.EqualityComparer);
// setup a 1-channel SheetBuilder for our private use
if (builder == null) builder = new SheetBuilder(TextureChannel.Alpha);