mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-21 02:08:12 +03:00
LibJS: Stop iterating lexically declared names once 'arguments' is found
In ECMAScriptFunctionObject::function_declaration_instantiation() we iterate over all lexically declared names of the function scope body to determine whether any of them is named 'arguments', because we don't need to create an arguments object in that case. We can also stop at that point, because the decision won't change anymore.
This commit is contained in:
parent
3ab22c8012
commit
b2bded390a
Notes:
sideshowbarker
2024-07-18 03:02:44 +09:00
Author: https://github.com/linusg Commit: https://github.com/SerenityOS/serenity/commit/b2bded390ac Pull-request: https://github.com/SerenityOS/serenity/pull/10365 Reviewed-by: https://github.com/IdanHo ✅ Reviewed-by: https://github.com/awesomekling ✅
@ -179,8 +179,10 @@ ThrowCompletionOr<void> ECMAScriptFunctionObject::function_declaration_instantia
|
||||
|
||||
if (!has_parameter_expressions && arguments_object_needed) {
|
||||
scope_body->for_each_lexically_declared_name([&](auto const& name) {
|
||||
if (name == arguments_name)
|
||||
if (name == arguments_name) {
|
||||
arguments_object_needed = false;
|
||||
return IterationDecision::Break;
|
||||
}
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user