From 54c95d44ce962c5830d3ea1e50136758e43e4a22 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Wed, 15 Apr 2020 22:16:55 +0200 Subject: [PATCH] LibJS: Functions with no variables don't need to create environment Just hand out the parent environment instead. --- Libraries/LibJS/Runtime/ScriptFunction.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Libraries/LibJS/Runtime/ScriptFunction.cpp b/Libraries/LibJS/Runtime/ScriptFunction.cpp index ab241fe331..ec1b6188da 100644 --- a/Libraries/LibJS/Runtime/ScriptFunction.cpp +++ b/Libraries/LibJS/Runtime/ScriptFunction.cpp @@ -72,7 +72,8 @@ LexicalEnvironment* ScriptFunction::create_environment() } } } - + if (variables.is_empty()) + return m_parent_environment; return heap().allocate(move(variables), m_parent_environment); }