From fc9e43728bcb81a57626848ee74b739aace86430 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Tue, 8 Dec 2020 18:04:54 +0100 Subject: [PATCH] LibJS: Stop creating a redundant lexical scope on function call We were scoping the arguments twice, first in execute_function_body(), and then again in enter_scope(). --- Libraries/LibJS/Runtime/ScriptFunction.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Libraries/LibJS/Runtime/ScriptFunction.cpp b/Libraries/LibJS/Runtime/ScriptFunction.cpp index 55bfb9f11e..1b39fbb6eb 100644 --- a/Libraries/LibJS/Runtime/ScriptFunction.cpp +++ b/Libraries/LibJS/Runtime/ScriptFunction.cpp @@ -127,7 +127,6 @@ Value ScriptFunction::execute_function_body() VM::InterpreterExecutionScope scope(*interpreter); auto& call_frame_args = vm.call_frame().arguments; - ArgumentVector arguments; for (size_t i = 0; i < m_parameters.size(); ++i) { auto parameter = m_parameters[i]; Value argument_value; @@ -145,11 +144,10 @@ Value ScriptFunction::execute_function_body() } else { argument_value = js_undefined(); } - arguments.append({ parameter.name, argument_value }); vm.current_scope()->put_to_scope(parameter.name, { argument_value, DeclarationKind::Var }); } - return interpreter->execute_statement(global_object(), m_body, move(arguments), ScopeType::Function); + return interpreter->execute_statement(global_object(), m_body, {}, ScopeType::Function); } Value ScriptFunction::call()