1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-30 22:18:11 +00:00

LibJS: Use HashMap::ensure_capacity() in enter_scope()

Preallocate some space in the scope variable map. This avoids a bunch
of incremental rehashing in the common case.
This commit is contained in:
Andreas Kling 2020-04-13 17:23:42 +02:00
parent 8f82f6c574
commit 8249280500

View file

@ -92,6 +92,7 @@ Value Interpreter::run(const Statement& statement, ArgumentVector arguments, Sco
void Interpreter::enter_scope(const ScopeNode& scope_node, ArgumentVector arguments, ScopeType scope_type)
{
HashMap<FlyString, Variable> scope_variables_with_declaration_kind;
scope_variables_with_declaration_kind.ensure_capacity(16);
for (auto& declaration : scope_node.variables()) {
for (auto& declarator : declaration.declarations()) {