mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 08:24:58 +00:00
AK: Move String::bytes() and String::operator==(String) to StringBase
The idea is to eventually get rid of protected state in StringBase. To do this, we first need to remove all references to m_data and m_short_string from String.
This commit is contained in:
parent
4364a28d3d
commit
54d149bc25
4 changed files with 21 additions and 19 deletions
|
@ -213,13 +213,6 @@ StringView String::bytes_as_string_view() const
|
|||
return StringView(bytes());
|
||||
}
|
||||
|
||||
ReadonlyBytes String::bytes() const
|
||||
{
|
||||
if (is_short_string())
|
||||
return m_short_string.bytes();
|
||||
return m_data->bytes();
|
||||
}
|
||||
|
||||
bool String::is_empty() const
|
||||
{
|
||||
return bytes().size() == 0;
|
||||
|
@ -291,13 +284,6 @@ Optional<size_t> String::find_byte_offset(StringView substring, size_t from_byte
|
|||
return {};
|
||||
}
|
||||
|
||||
bool String::operator==(String const& other) const
|
||||
{
|
||||
if (is_short_string())
|
||||
return m_data == other.m_data;
|
||||
return bytes_as_string_view() == other.bytes_as_string_view();
|
||||
}
|
||||
|
||||
bool String::operator==(FlyString const& other) const
|
||||
{
|
||||
if (reinterpret_cast<uintptr_t>(m_data) == other.data({}))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue