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

AK: Implement all comparison operators for StringView

This commit is contained in:
Daniel Bertalan 2022-01-29 15:49:33 +01:00 committed by Andreas Kling
parent 2e5a9b4fab
commit ca58c71faa
2 changed files with 24 additions and 23 deletions

View file

@ -203,15 +203,7 @@ template Optional<long long> StringView::to_uint() const;
bool StringView::operator==(const String& string) const
{
if (string.is_null())
return !m_characters;
if (!m_characters)
return false;
if (m_length != string.length())
return false;
if (m_characters == string.characters())
return true;
return !__builtin_memcmp(m_characters, string.characters(), m_length);
return *this == string.view();
}
String StringView::to_string() const { return String { *this }; }