LibJS: Don't track "last result" of ScopeNode if we don't need it

This prevents unnecessary bytecode register allocation.
This commit is contained in:
Andreas Kling 2025-04-07 15:59:30 +02:00 committed by Andreas Kling
commit 9c0b185ab8
Notes: github-actions[bot] 2025-04-08 16:54:20 +00:00

View file

@ -56,8 +56,10 @@ Bytecode::CodeGenerationErrorOr<Optional<ScopedOperand>> ScopeNode::generate_byt
Optional<ScopedOperand> last_result; Optional<ScopedOperand> last_result;
for (auto& child : children()) { for (auto& child : children()) {
auto result = TRY(child->generate_bytecode(generator)); auto result = TRY(child->generate_bytecode(generator));
if (result.has_value()) if (generator.must_propagate_completion()) {
last_result = result; if (result.has_value())
last_result = result;
}
if (generator.is_current_block_terminated()) if (generator.is_current_block_terminated())
break; break;
} }