AK: Remove excessive hashing caused by FlyString table

Before this change, the global FlyString table looked like this:

    HashMap<StringView, Detail::StringBase>

After this change, we have:

    HashTable<Detail::StringData const*, FlyStringTableHashTraits>

The custom hash traits are used to extract the stored hash from
StringData which avoids having to rehash the StringView repeatedly like
we did before.

This necessitated a handful of smaller changes to make it work.
This commit is contained in:
Andreas Kling 2024-03-23 14:54:23 +01:00
commit a88799c032
Notes: sideshowbarker 2024-07-17 11:30:05 +09:00
6 changed files with 28 additions and 28 deletions

View file

@ -44,22 +44,15 @@ public:
void operator delete(void* ptr)
{
free(ptr);
}
void unref() const
{
if (m_is_fly_string && m_ref_count == 2) {
m_is_fly_string = false; // Otherwise unref from did_destroy_fly_string_data will cause infinite recursion.
FlyString::did_destroy_fly_string_data({}, *this);
}
RefCounted::unref();
kfree_sized(ptr, allocation_size_for_string_data(static_cast<StringData const*>(ptr)->m_byte_count));
}
~StringData()
{
if (m_substring)
substring_data().superstring->unref();
if (m_is_fly_string)
FlyString::did_destroy_fly_string_data({}, *this);
}
SubstringData const& substring_data() const