mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-01 13:49:16 +00:00
JSSpecCompiler: Elide nested TreeList
nodes
This commit is contained in:
parent
f30815b534
commit
14a86c8fd6
Notes:
sideshowbarker
2024-07-17 03:45:48 +09:00
Author: https://github.com/DanShaders
Commit: 14a86c8fd6
Pull-request: https://github.com/SerenityOS/serenity/pull/21263
Reviewed-by: https://github.com/gmta ✅
4 changed files with 23 additions and 12 deletions
|
@ -83,10 +83,22 @@ Vector<NodeSubtreePointer> IfElseIfChain::subtrees()
|
|||
return result;
|
||||
}
|
||||
|
||||
TreeList::TreeList(Vector<Tree>&& trees)
|
||||
{
|
||||
for (auto const& tree : trees) {
|
||||
if (tree->is_list()) {
|
||||
for (auto const& nested_tree : as<TreeList>(tree)->m_trees)
|
||||
m_trees.append(nested_tree);
|
||||
} else {
|
||||
m_trees.append(tree);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Vector<NodeSubtreePointer> TreeList::subtrees()
|
||||
{
|
||||
Vector<NodeSubtreePointer> result;
|
||||
for (auto& expression : m_expressions)
|
||||
for (auto& expression : m_trees)
|
||||
result.append({ &expression });
|
||||
return result;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue