mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-31 05:09:12 +00:00
LibJS: Skip some declarative env allocations in function instantiation
If all lexical declaration use local variables then there is no need to allocate declarative environment. With this change we skip ~3x more environment allocations on Github.
This commit is contained in:
parent
5da9af435e
commit
f21c0f9dcd
Notes:
sideshowbarker
2024-07-16 19:17:47 +09:00
Author: https://github.com/kalenikaliaksandr
Commit: f21c0f9dcd
Pull-request: https://github.com/SerenityOS/serenity/pull/24213
3 changed files with 13 additions and 2 deletions
|
@ -1440,6 +1440,16 @@ void SequenceExpression::dump(int indent) const
|
|||
expression->dump(indent + 1);
|
||||
}
|
||||
|
||||
bool ScopeNode::has_non_local_lexical_declarations() const
|
||||
{
|
||||
bool result = false;
|
||||
MUST(for_each_lexically_declared_identifier([&](Identifier const& identifier) {
|
||||
if (!identifier.is_local())
|
||||
result = true;
|
||||
}));
|
||||
return result;
|
||||
}
|
||||
|
||||
ThrowCompletionOr<void> ScopeNode::for_each_lexically_scoped_declaration(ThrowCompletionOrVoidCallback<Declaration const&>&& callback) const
|
||||
{
|
||||
for (auto& declaration : m_lexical_declarations)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue