From cf39d5c512655cfd01d9da53531e965f024396c2 Mon Sep 17 00:00:00 2001 From: Jesse Miller Date: Fri, 5 Sep 2025 15:52:41 -0600 Subject: [PATCH] Glphkey.hash CityHash64 -> hash.int --- src/font/SharedGrid.zig | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/font/SharedGrid.zig b/src/font/SharedGrid.zig index ff05d1a59..e79fd117f 100644 --- a/src/font/SharedGrid.zig +++ b/src/font/SharedGrid.zig @@ -332,11 +332,15 @@ const GlyphKey = struct { const Context = struct { pub fn hash(_: Context, key: GlyphKey) u64 { + // Packed is a u64 but std.hash.int improves uniformity and + // avoids collisions in our hashmap. const packed_key = Packed.from(key); - return std.hash.CityHash64.hash(std.mem.asBytes(&packed_key)); + return std.hash.int(@as(u64, @bitCast(packed_key))); } pub fn eql(_: Context, a: GlyphKey, b: GlyphKey) bool { + // Packed checks glyphs but in most cases the glyphs are NOT + // equal so the first check leads to increased throughput. return a.glyph == b.glyph and Packed.from(a) == Packed.from(b); } };