Serenity Operating System
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

AK: Add some string comparison operators

Some of these are very inefficient. It's nice to have some optimization
opportunities in the future though. :^)

+34
+17
AK/FlyString.cpp
··· 104 104 return { characters(), length() }; 105 105 } 106 106 107 + bool FlyString::operator==(const String& string) const 108 + { 109 + if (m_impl == string.impl()) 110 + return true; 111 + return String(m_impl.ptr()) == string; 112 + } 113 + 114 + bool FlyString::operator==(const StringView& string) const 115 + { 116 + return String(string) == String(m_impl.ptr()); 117 + } 118 + 119 + bool FlyString::operator==(const char* string) const 120 + { 121 + return String(string) == String(m_impl.ptr()); 122 + } 123 + 107 124 }
+9
AK/FlyString.h
··· 42 42 bool operator==(const FlyString& other) const { return m_impl == other.m_impl; } 43 43 bool operator!=(const FlyString& other) const { return m_impl != other.m_impl; } 44 44 45 + bool operator==(const String&) const; 46 + bool operator!=(const String& string) const { return !(*this == string); } 47 + 48 + bool operator==(const StringView&) const; 49 + bool operator!=(const StringView& string) const { return !(*this == string); } 50 + 51 + bool operator==(const char*) const; 52 + bool operator!=(const char* string) const { return !(*this == string); } 53 + 45 54 const StringImpl* impl() const { return m_impl; } 46 55 const char* characters() const { return m_impl ? m_impl->characters() : nullptr; } 47 56 size_t length() const { return m_impl ? m_impl->length() : 0; }
+5
AK/String.cpp
··· 50 50 m_impl = StringImpl::create(view.characters_without_null_termination(), view.length()); 51 51 } 52 52 53 + bool String::operator==(const FlyString& fly_string) const 54 + { 55 + return *this == String(fly_string.impl()); 56 + } 57 + 53 58 bool String::operator==(const String& other) const 54 59 { 55 60 if (!m_impl)
+3
AK/String.h
··· 148 148 bool operator==(const StringView&) const; 149 149 bool operator!=(const StringView& other) const { return !(*this == other); } 150 150 151 + bool operator==(const FlyString&) const; 152 + bool operator!=(const FlyString& other) const { return !(*this == other); } 153 + 151 154 bool operator<(const String&) const; 152 155 bool operator<(const char*) const; 153 156 bool operator>=(const String& other) const { return !(*this < other); }