1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 19:47:44 +00:00

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
parent 391352c112
commit bf46845819

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