Skip to content

Commit 962080e

Browse files
committed
ControlBlocks: Remove substack checks from until and while
Repeat until/while loop can't be skipped if it has an empty body.
1 parent 5b16bdc commit 962080e

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

src/blocks/controlblocks.cpp

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -63,24 +63,20 @@ void ControlBlocks::compileRepeat(Compiler *compiler)
6363
void ControlBlocks::compileRepeatUntil(Compiler *compiler)
6464
{
6565
auto substack = compiler->inputBlock(SUBSTACK);
66-
if (substack) {
67-
compiler->addInstruction(vm::OP_UNTIL_LOOP);
68-
compiler->addInput(CONDITION);
69-
compiler->addInstruction(vm::OP_BEGIN_UNTIL_LOOP);
70-
compiler->moveToSubstack(substack, Compiler::SubstackType::Loop);
71-
}
66+
compiler->addInstruction(vm::OP_UNTIL_LOOP);
67+
compiler->addInput(CONDITION);
68+
compiler->addInstruction(vm::OP_BEGIN_UNTIL_LOOP);
69+
compiler->moveToSubstack(substack, Compiler::SubstackType::Loop);
7270
}
7371

7472
void ControlBlocks::compileRepeatWhile(Compiler *compiler)
7573
{
7674
auto substack = compiler->inputBlock(SUBSTACK);
77-
if (substack) {
78-
compiler->addInstruction(vm::OP_UNTIL_LOOP);
79-
compiler->addInput(CONDITION);
80-
compiler->addInstruction(vm::OP_NOT);
81-
compiler->addInstruction(vm::OP_BEGIN_UNTIL_LOOP);
82-
compiler->moveToSubstack(substack, Compiler::SubstackType::Loop);
83-
}
75+
compiler->addInstruction(vm::OP_UNTIL_LOOP);
76+
compiler->addInput(CONDITION);
77+
compiler->addInstruction(vm::OP_NOT);
78+
compiler->addInstruction(vm::OP_BEGIN_UNTIL_LOOP);
79+
compiler->moveToSubstack(substack, Compiler::SubstackType::Loop);
8480
}
8581

8682
void ControlBlocks::compileRepeatForEach(Compiler *compiler)

0 commit comments

Comments
 (0)