mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-01-07 05:43:20 +00:00
Micro-optimize GlyphKey Context
Use fast hash function on key for better distribution. Direct compare glyph in eql to avoid Packed.from() if not neccessary. 16% -> 6.4% reduction during profiling runs.
This commit is contained in:
@@ -332,11 +332,12 @@ const GlyphKey = struct {
|
||||
|
||||
const Context = struct {
|
||||
pub fn hash(_: Context, key: GlyphKey) u64 {
|
||||
return @bitCast(Packed.from(key));
|
||||
const packed_key = Packed.from(key);
|
||||
return std.hash.CityHash64.hash(std.mem.asBytes(&packed_key));
|
||||
}
|
||||
|
||||
pub fn eql(_: Context, a: GlyphKey, b: GlyphKey) bool {
|
||||
return Packed.from(a) == Packed.from(b);
|
||||
return a.glyph == b.glyph and Packed.from(a) == Packed.from(b);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user