mirror of
https://github.com/RGBCube/serenity
synced 2025-07-10 03:47:34 +00:00
AK: Add StringView::hash()
This grabs the hash from the underlying StringImpl if there is one, otherwise it's computed on the fly.
This commit is contained in:
parent
bb32fd8bfa
commit
d38bd3935b
2 changed files with 11 additions and 0 deletions
|
@ -109,4 +109,13 @@ unsigned StringView::to_uint(bool& ok) const
|
|||
return value;
|
||||
}
|
||||
|
||||
unsigned StringView::hash() const
|
||||
{
|
||||
if (is_empty())
|
||||
return 0;
|
||||
if (m_impl)
|
||||
return m_impl->hash();
|
||||
return string_hash(characters_without_null_termination(), length());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue