Forráskód Böngészése

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%.
Andreas Kling 3 éve
szülő
commit
bf46845819
1 módosított fájl, 1 hozzáadás és 1 törlés
  1. 1 1
      Userland/Libraries/LibJS/Lexer.cpp

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