diff --git a/AK/FlyString.cpp b/AK/FlyString.cpp index c537ac14e6e..e320b95c2d4 100644 --- a/AK/FlyString.cpp +++ b/AK/FlyString.cpp @@ -63,6 +63,10 @@ FlyString::FlyString(const String& string) { if (string.is_null()) return; + if (string.impl()->is_fly()) { + m_impl = string.impl(); + return; + } auto it = fly_impls().find(const_cast(string.impl())); if (it == fly_impls().end()) { fly_impls().set(const_cast(string.impl())); diff --git a/AK/FlyString.h b/AK/FlyString.h index cbab71a26d1..8f92396928b 100644 --- a/AK/FlyString.h +++ b/AK/FlyString.h @@ -33,10 +33,30 @@ namespace AK { class FlyString { public: FlyString() {} + FlyString(const FlyString& other) + : m_impl(other.impl()) + { + } + FlyString(FlyString&& other) + : m_impl(move(other.m_impl)) + { + } FlyString(const String&); FlyString(const StringView&); FlyString(const char*); + FlyString& operator=(const FlyString& other) + { + m_impl = other.m_impl; + return *this; + } + + FlyString& operator=(FlyString&& other) + { + m_impl = move(other.m_impl); + return *this; + } + bool is_empty() const { return !m_impl || !m_impl->length(); } bool is_null() const { return !m_impl; }