1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 08:24:58 +00:00

AK: Move String::hash() and String::String() to StringBase

This commit is contained in:
Dan Klishch 2023-10-28 15:47:59 -04:00 committed by Andrew Kaster
parent 1b09a1851e
commit d6290c4684
4 changed files with 16 additions and 16 deletions

View file

@ -66,6 +66,15 @@ ReadonlyBytes StringBase::bytes() const
return m_data->bytes();
}
u32 StringBase::hash() const
{
if (is_short_string()) {
auto bytes = this->bytes();
return string_hash(reinterpret_cast<char const*>(bytes.data()), bytes.size());
}
return m_data->hash();
}
bool StringBase::operator==(StringBase const& other) const
{
if (is_short_string())