diff options
author | Robin Burchell <robin+git@viroteck.net> | 2019-06-03 18:27:56 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-06-03 20:27:05 +0200 |
commit | f9ba7adae2efaa2e2bdc47a13ff22aed401261b3 (patch) | |
tree | 87e22463fdd5c5e14d2f4cf9ca7e2ada15815a56 /AK/AKString.h | |
parent | 8fecc0eaeeacf0b623f495258c32a785c67b0c32 (diff) | |
download | serenity-f9ba7adae2efaa2e2bdc47a13ff22aed401261b3.zip |
StringView: Make construction of String from a StringView containing a String cheaper
... at the cost of an additional pointer per view.
Diffstat (limited to 'AK/AKString.h')
-rw-r--r-- | AK/AKString.h | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/AK/AKString.h b/AK/AKString.h index e75172a870..617bb6ab39 100644 --- a/AK/AKString.h +++ b/AK/AKString.h @@ -36,9 +36,12 @@ public: String() {} - String(StringView view) - : m_impl(StringImpl::create(view.characters(), view.length())) + String(const StringView& view) { + if (view.m_string) + *this = String(*view.m_string); + else + m_impl = StringImpl::create(view.characters(), view.length()); } String(const String& other) |