diff --git a/AK/FlyString.cpp b/AK/FlyString.cpp index 8acc94d67ac..d1b31e14497 100644 --- a/AK/FlyString.cpp +++ b/AK/FlyString.cpp @@ -73,11 +73,6 @@ FlyString::FlyString(StringView const& string) } } -FlyString::FlyString(const char* string) - : FlyString(static_cast(string)) -{ -} - template Optional FlyString::to_int() const { diff --git a/AK/FlyString.h b/AK/FlyString.h index ea3177eec8c..2db89366dfd 100644 --- a/AK/FlyString.h +++ b/AK/FlyString.h @@ -23,7 +23,10 @@ public: } FlyString(const String&); FlyString(const StringView&); - FlyString(const char*); + FlyString(const char* string) + : FlyString(static_cast(string)) + { + } FlyString& operator=(const FlyString& other) { diff --git a/AK/String.cpp b/AK/String.cpp index f8301e5bded..17eb0ac745c 100644 --- a/AK/String.cpp +++ b/AK/String.cpp @@ -15,11 +15,6 @@ namespace AK { -String::String(const StringView& view) -{ - m_impl = StringImpl::create(view.characters_without_null_termination(), view.length()); -} - bool String::operator==(const FlyString& fly_string) const { return *this == String(fly_string.impl()); @@ -72,11 +67,6 @@ bool String::operator>(const String& other) const return strcmp(characters(), other.characters()) > 0; } -String String::empty() -{ - return StringImpl::the_empty_stringimpl(); -} - bool String::copy_characters_to_buffer(char* buffer, size_t buffer_size) const { // We must fit at least the NUL-terminator. @@ -456,11 +446,6 @@ bool String::operator==(const char* cstring) const return !__builtin_strcmp(characters(), cstring); } -StringView String::view() const -{ - return { characters(), length() }; -} - InputStream& operator>>(InputStream& stream, String& string) { StringBuilder builder; diff --git a/AK/String.h b/AK/String.h index 0e11bcd7bb4..b1d453e60dc 100644 --- a/AK/String.h +++ b/AK/String.h @@ -42,7 +42,11 @@ public: ~String() = default; String() = default; - String(const StringView&); + + String(const StringView& view) + { + m_impl = StringImpl::create(view.characters_without_null_termination(), view.length()); + } String(const String& other) : m_impl(const_cast(other).m_impl) @@ -203,7 +207,10 @@ public: [[nodiscard]] String isolated_copy() const; - [[nodiscard]] static String empty(); + [[nodiscard]] static String empty() + { + return StringImpl::the_empty_stringimpl(); + } [[nodiscard]] StringImpl* impl() { return m_impl.ptr(); } [[nodiscard]] const StringImpl* impl() const { return m_impl.ptr(); } @@ -265,7 +272,10 @@ public: return formatted("{}", value); } - [[nodiscard]] StringView view() const; + [[nodiscard]] StringView view() const + { + return { characters(), length() }; + } int replace(const String& needle, const String& replacement, bool all_occurrences = false); size_t count(const String& needle) const;