diff options
author | Andreas Kling <kling@serenityos.org> | 2020-04-13 12:05:19 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-04-13 12:27:05 +0200 |
commit | 02e0fab19af9cf892ee651e5916c9895703cefdd (patch) | |
tree | f25d1d1980f6f5c05d364a53894a9042fdd2fad4 /AK/FlyString.h | |
parent | d1ffdea55014bcf900a5cda175bb68356d28c6c3 (diff) | |
download | serenity-02e0fab19af9cf892ee651e5916c9895703cefdd.zip |
AK: Let FlyString::hash() assume that the string was already hashed
Since the FlyString deduplication mechanism uses a HashTable, we know
that any StringImpl inside a non-null FlyString will already have its
lazily computed hash.
Diffstat (limited to 'AK/FlyString.h')
-rw-r--r-- | AK/FlyString.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/AK/FlyString.h b/AK/FlyString.h index a306682813..b66ab76024 100644 --- a/AK/FlyString.h +++ b/AK/FlyString.h @@ -55,7 +55,7 @@ public: const char* characters() const { return m_impl ? m_impl->characters() : nullptr; } size_t length() const { return m_impl ? m_impl->length() : 0; } - u32 hash() const { return m_impl ? m_impl->hash() : 0; } + [[gnu::always_inline]] inline u32 hash() const { return m_impl ? m_impl->existing_hash() : 0; } StringView view() const; @@ -73,7 +73,7 @@ private: template<> struct Traits<FlyString> : public GenericTraits<FlyString> { - static unsigned hash(const FlyString& s) { return s.impl() ? s.impl()->hash() : 0; } + static unsigned hash(const FlyString& s) { return s.hash(); } }; } |