mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-24 13:35:12 +00:00
LibJS: Elide empty variable environment for default parameters
No need to create a separate variable environment if all the parameters are going into locals anyway.
This commit is contained in:
parent
8be966524f
commit
24c2a9de6f
1 changed files with 13 additions and 1 deletions
|
@ -136,7 +136,19 @@ CodeGenerationErrorOr<void> Generator::emit_function_declaration_instantiation(E
|
|||
}
|
||||
}
|
||||
} else {
|
||||
emit<Op::CreateVariableEnvironment>(function.m_var_environment_bindings_count);
|
||||
bool has_non_local_parameters = false;
|
||||
if (scope_body) {
|
||||
for (auto const& variable_to_initialize : function.m_var_names_to_initialize_binding) {
|
||||
auto const& id = variable_to_initialize.identifier;
|
||||
if (!id.is_local()) {
|
||||
has_non_local_parameters = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (has_non_local_parameters)
|
||||
emit<Op::CreateVariableEnvironment>(function.m_var_environment_bindings_count);
|
||||
|
||||
if (scope_body) {
|
||||
for (auto const& variable_to_initialize : function.m_var_names_to_initialize_binding) {
|
||||
|
|
Loading…
Add table
Reference in a new issue