From 048a0ab32b0fbcdd9c6723b2936cd6283b4b34ba Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Mon, 26 Jan 2026 17:54:48 +0100 Subject: [PATCH] AK: Cache hashes for fly string interning HashTable only stores per-bucket hash when traits say equality is slow. The FlyString/Utf16FlyString interning tables compare full string data, so equality is not cheap. Mark these traits as slow-equality so hashes are stored and checked first, reducing probe cost in hot interning lookups. --- AK/FlyString.cpp | 1 + AK/Utf16FlyString.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/AK/FlyString.cpp b/AK/FlyString.cpp index 468f97519c..fefdc76ead 100644 --- a/AK/FlyString.cpp +++ b/AK/FlyString.cpp @@ -17,6 +17,7 @@ namespace AK { struct FlyStringTableHashTraits : public Traits { static u32 hash(Detail::StringData const* string) { return string->hash(); } static bool equals(Detail::StringData const* a, Detail::StringData const* b) { return *a == *b; } + static constexpr bool may_have_slow_equality_check() { return true; } }; static auto& all_fly_strings() diff --git a/AK/Utf16FlyString.cpp b/AK/Utf16FlyString.cpp index 921ec447bf..921769558a 100644 --- a/AK/Utf16FlyString.cpp +++ b/AK/Utf16FlyString.cpp @@ -13,6 +13,7 @@ namespace AK { struct Utf16FlyStringTableHashTraits : public Traits { static u32 hash(Detail::Utf16StringData const* string) { return string->hash(); } static bool equals(Detail::Utf16StringData const* a, Detail::Utf16StringData const* b) { return *a == *b; } + static constexpr bool may_have_slow_equality_check() { return true; } }; static auto& all_utf16_fly_strings()