From 824928050025b89498e3b740d2513fb65e655207 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Mon, 13 Apr 2020 17:23:42 +0200 Subject: [PATCH] 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. --- Libraries/LibJS/Interpreter.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Libraries/LibJS/Interpreter.cpp b/Libraries/LibJS/Interpreter.cpp index d79b57f2db..22f8489d87 100644 --- a/Libraries/LibJS/Interpreter.cpp +++ b/Libraries/LibJS/Interpreter.cpp @@ -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 scope_variables_with_declaration_kind; + scope_variables_with_declaration_kind.ensure_capacity(16); for (auto& declaration : scope_node.variables()) { for (auto& declarator : declaration.declarations()) {