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%.
This commit is contained in:
Andreas Kling 2021-09-18 18:29:32 +02:00
commit bf46845819
Notes: sideshowbarker 2024-07-18 03:43:13 +09:00

View file

@ -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; });