mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 04:09:13 +00:00
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:
parent
8bfad24708
commit
a88799c032
Notes:
sideshowbarker
2024-07-17 11:30:05 +09:00
Author: https://github.com/awesomekling
Commit: a88799c032
Pull-request: https://github.com/SerenityOS/serenity/pull/23690
Reviewed-by: https://github.com/Hendiadyoin1
6 changed files with 28 additions and 28 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue