diff options
author | Andreas Kling <kling@serenityos.org> | 2020-10-04 17:21:46 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-10-04 19:25:49 +0200 |
commit | cfd141b4f9dc1352bdee22787a4c66fbac5127b5 (patch) | |
tree | d241718401f6bb59268660dc92f13ac3def40cad | |
parent | 5de5af60c1f34315f6f2546359f35ecee35a3d67 (diff) | |
download | serenity-cfd141b4f9dc1352bdee22787a4c66fbac5127b5.zip |
LibJS: Avoid unnecessary StringImpl copy in StringOrSymbol(String)
-rw-r--r-- | Libraries/LibJS/Runtime/StringOrSymbol.h | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/Libraries/LibJS/Runtime/StringOrSymbol.h b/Libraries/LibJS/Runtime/StringOrSymbol.h index ea66d2fcd0..01ca65b6ce 100644 --- a/Libraries/LibJS/Runtime/StringOrSymbol.h +++ b/Libraries/LibJS/Runtime/StringOrSymbol.h @@ -51,8 +51,10 @@ public: } StringOrSymbol(const String& string) - : m_ptr(StringImpl::create(string.characters(), string.length()).leak_ref()) + : m_ptr(string.impl()) { + ASSERT(!string.is_null()); + static_cast<const StringImpl*>(m_ptr)->ref(); } ~StringOrSymbol() |