mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 12:37:44 +00:00
LibJS: Skip declarative env in block statement without lexical decls
The idea here is simple: If the block statement doesn't contain any lexical declarations, we don't need to allocate, initialize and eventually garbage collect a new declarative environment. This even makes lookups across nested blocks slightly faster as we don't have to traverse a chain of empty environments anymore - instead, the execution context just stores the outermost non-empty one. This doesn't speed up test-js considerably, but has a noticeable effect on test262 and real-world web content :^)
This commit is contained in:
parent
d609dde7b0
commit
8074bdc049
2 changed files with 16 additions and 5 deletions
|
@ -183,6 +183,9 @@ public:
|
|||
void add_lexical_declaration(NonnullRefPtr<Declaration> variables);
|
||||
void add_hoisted_function(NonnullRefPtr<FunctionDeclaration> declaration);
|
||||
|
||||
[[nodiscard]] bool has_lexical_declarations() const { return !m_lexical_declarations.is_empty(); }
|
||||
[[nodiscard]] bool has_var_declarations() const { return !m_var_declarations.is_empty(); }
|
||||
|
||||
void for_each_lexically_scoped_declaration(IteratorOrVoidFunction<Declaration const&>&& callback) const;
|
||||
void for_each_lexically_declared_name(IteratorOrVoidFunction<FlyString const&>&& callback) const;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue