mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-01 08:48:49 +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
b971e1ece0
commit
c528c01745
Notes:
github-actions[bot]
2025-03-20 23:59:26 +00:00
Author: https://github.com/awesomekling
Commit: c528c01745
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4027
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
Add a link
Reference in a new issue