From b00b461b317eaed1cf027731ea8aaec3fe857edc Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Fri, 8 Oct 2021 01:32:12 +0200 Subject: [PATCH] LibJS: Pre-size a HashTable in function_declaration_instantiation() The dynamic resizing of this hash table was showing up in profiles. Since we have an idea of how big it will get, use ensure_capacity(). --- Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp b/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp index ce15244e39..e998236294 100644 --- a/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp @@ -287,6 +287,8 @@ ThrowCompletionOr ECMAScriptFunctionObject::function_declaration_instantia Environment* var_environment; HashTable instantiated_var_names; + if (scope_body) + instantiated_var_names.ensure_capacity(scope_body->var_declaration_count()); if (!has_parameter_expressions) { if (scope_body) {