From 2837dabf7818666a9366d659d2da3b9055140740 Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Fri, 23 Jan 2026 11:16:12 +0100 Subject: feat: make Next iterator instruction faster and more efficient Branching control is delegated directly to the Next instruction, which now takes the location of loop exit as first argument. It avoids the use of JumpFalse, plus the stack storage for the condition. --- parser/tokens.go | 2 ++ 1 file changed, 2 insertions(+) (limited to 'parser/tokens.go') diff --git a/parser/tokens.go b/parser/tokens.go index a0a93fa..7a241f3 100644 --- a/parser/tokens.go +++ b/parser/tokens.go @@ -79,6 +79,8 @@ func newCall(pos int, arg ...any) Token { return newToken(lang.Cal func newGoto(label string, pos int) Token { return newToken(lang.Goto, label, pos) } func newLabel(label string, pos int) Token { return newToken(lang.Label, label, pos) } func newJumpFalse(label string, pos int) Token { return newToken(lang.JumpFalse, label, pos) } +func newNext(label string, pos int) Token { return newToken(lang.Next, label, pos) } +func newStop(pos int) Token { return newToken(lang.Stop, "", pos) } func newGrow(size, pos int) Token { return newToken(lang.Grow, "", pos, size) } func newSemicolon(pos int) Token { return newToken(lang.Semicolon, "", pos) } func newEqualSet(pos int) Token { return newToken(lang.EqualSet, "", pos) } -- cgit v1.2.3