aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler/qv4codegen.cpp
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2023-08-25 13:51:00 +0200
committerUlf Hermann <ulf.hermann@qt.io>2023-08-25 23:58:12 +0200
commit8e4f2542a4dccf186b13b70a128cd4e10c35acdb (patch)
tree220e722d9c3876ef353aa84c73699a86cff303f0 /src/qml/compiler/qv4codegen.cpp
parent3ca5a7b3b6e7d6ddf46de8d5087faec6c9a70c92 (diff)
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 <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/compiler/qv4codegen.cpp')
-rw-r--r--src/qml/compiler/qv4codegen.cpp11
1 files changed, 6 insertions, 5 deletions
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<void()> 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();