mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 00:50:22 +00:00
AK: Implement FlyString's comparison operators in terms of StringView's
This commit is contained in:
parent
ca58c71faa
commit
5b3ba2d9ad
Notes:
sideshowbarker
2024-07-17 20:00:53 +09:00
Author: https://github.com/BertalanD Commit: https://github.com/SerenityOS/serenity/commit/5b3ba2d9adb Pull-request: https://github.com/SerenityOS/serenity/pull/12201
1 changed files with 3 additions and 19 deletions
|
@ -117,33 +117,17 @@ FlyString FlyString::to_lowercase() const
|
|||
|
||||
bool FlyString::operator==(const String& other) const
|
||||
{
|
||||
if (m_impl == other.impl())
|
||||
return true;
|
||||
|
||||
if (!m_impl)
|
||||
return !other.impl();
|
||||
|
||||
if (!other.impl())
|
||||
return false;
|
||||
|
||||
if (length() != other.length())
|
||||
return false;
|
||||
|
||||
return !__builtin_memcmp(characters(), other.characters(), length());
|
||||
return m_impl == other.impl() || view() == other.view();
|
||||
}
|
||||
|
||||
bool FlyString::operator==(StringView string) const
|
||||
{
|
||||
return *this == String(string);
|
||||
return view() == string;
|
||||
}
|
||||
|
||||
bool FlyString::operator==(const char* string) const
|
||||
{
|
||||
if (is_null())
|
||||
return !string;
|
||||
if (!string)
|
||||
return false;
|
||||
return !__builtin_strcmp(m_impl->characters(), string);
|
||||
return view() == string;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue