diff options
author | Andreas Kling <kling@serenityos.org> | 2021-09-18 18:29:32 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-09-18 19:54:24 +0200 |
commit | bf46845819a1575a41531789bfa11dbaef25e706 (patch) | |
tree | a189e5a94381464a661f86173bd0534f0ea486d3 /Userland | |
parent | 391352c1121e1709385d8dc47ab81980f24c5a6b (diff) | |
download | serenity-bf46845819a1575a41531789bfa11dbaef25e706.zip |
LibJS: Avoid a temporary AK::String when lexing already-seen identifiers
By using the FlyString(StringView) constructor instead of the
FlyString(String) one, we can dodge a temporary String construction.
This improves parsing time on a large chunk of JS by ~1.6%.
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibJS/Lexer.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/Userland/Libraries/LibJS/Lexer.cpp b/Userland/Libraries/LibJS/Lexer.cpp index 3ef63870f3..7b58a84f32 100644 --- a/Userland/Libraries/LibJS/Lexer.cpp +++ b/Userland/Libraries/LibJS/Lexer.cpp @@ -614,7 +614,7 @@ Token Lexer::next() code_point = is_identifier_middle(identifier_length); } while (code_point.has_value()); - identifier = builder.build(); + identifier = builder.string_view(); m_parsed_identifiers->identifiers.set(*identifier); auto it = s_keywords.find(identifier->hash(), [&](auto& entry) { return entry.key == identifier; }); |