AK: Implement FlyString's comparison operators in terms of StringView's

This commit is contained in:
Daniel Bertalan 2022-01-29 15:57:31 +01:00 committed by Andreas Kling
parent ca58c71faa
commit 5b3ba2d9ad
Notes: sideshowbarker 2024-07-17 20:00:53 +09:00

View file

@ -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;
}
}