summaryrefslogtreecommitdiff
path: root/AK/AKString.h
diff options
context:
space:
mode:
authorRobin Burchell <robin+git@viroteck.net>2019-06-03 18:27:56 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-06-03 20:27:05 +0200
commitf9ba7adae2efaa2e2bdc47a13ff22aed401261b3 (patch)
tree87e22463fdd5c5e14d2f4cf9ca7e2ada15815a56 /AK/AKString.h
parent8fecc0eaeeacf0b623f495258c32a785c67b0c32 (diff)
downloadserenity-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.h7
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)