From 8e4f2542a4dccf186b13b70a128cd4e10c35acdb Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Fri, 25 Aug 2023 13:51:00 +0200 Subject: QtQml: Don't generate an unwind handler for for..in loops We only need the unwind handler for for..of loops in order to close the iterator. Change-Id: Ieae67cf852fd858e0c1956889d4cf5b40a660b7e Reviewed-by: Fabian Kosmale --- src/qml/compiler/qv4codegen.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/qml/compiler/qv4codegen.cpp') diff --git a/src/qml/compiler/qv4codegen.cpp b/src/qml/compiler/qv4codegen.cpp index c43bdd8387..2df5a02998 100644 --- a/src/qml/compiler/qv4codegen.cpp +++ b/src/qml/compiler/qv4codegen.cpp @@ -3600,15 +3600,16 @@ bool Codegen::visit(ForEachStatement *ast) BytecodeGenerator::Label end = bytecodeGenerator->newLabel(); { - auto cleanup = [ast, iterator, iteratorDone, this]() { - if (ast->type == ForEachType::Of) { + std::function cleanup; + if (ast->type == ForEachType::Of) { + cleanup = [iterator, iteratorDone, this]() { iterator.loadInAccumulator(); Instruction::IteratorClose close; close.done = iteratorDone.stackSlot(); bytecodeGenerator->addInstruction(close); - } - }; - ControlFlowLoop flow(this, &end, &in, cleanup); + }; + } + ControlFlowLoop flow(this, &end, &in, std::move(cleanup)); bytecodeGenerator->addLoopStart(in); in.link(); iterator.loadInAccumulator(); -- cgit v1.2.3