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.
This commit is contained in:
parent
81bee185e6
commit
048a0ab32b
2 changed files with 2 additions and 0 deletions
|
|
@ -17,6 +17,7 @@ namespace AK {
|
|||
struct FlyStringTableHashTraits : public Traits<Detail::StringData const*> {
|
||||
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()
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ namespace AK {
|
|||
struct Utf16FlyStringTableHashTraits : public Traits<Detail::Utf16StringData const*> {
|
||||
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()
|
||||
|
|
|
|||
Loading…
Reference in a new issue