remove another 40M/min of boxing junk by specializing the key comparer on SpriteFont's dict
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user