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
Notes: sideshowbarker 2024-07-19 07:37:42 +09:00

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()) {