From 5b3ba2d9adbd068a168183a42423a42f2bcdd44e Mon Sep 17 00:00:00 2001 From: Daniel Bertalan Date: Sat, 29 Jan 2022 15:57:31 +0100 Subject: [PATCH] AK: Implement FlyString's comparison operators in terms of StringView's --- AK/FlyString.cpp | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/AK/FlyString.cpp b/AK/FlyString.cpp index 20b8e2ab04..0bb1b63c52 100644 --- a/AK/FlyString.cpp +++ b/AK/FlyString.cpp @@ -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; } }