From 873588dc5f04bfc37006c3dc6ceb9a495ea503f2 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Wed, 21 Dec 2022 15:35:40 -0300 Subject: Simplification in opcodes for numerical 'for' As the control variable is read only, the code doesn't need to keep an internal copy of it. --- lparser.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lparser.c') diff --git a/lparser.c b/lparser.c index 79b2317b..ff6f4009 100644 --- a/lparser.c +++ b/lparser.c @@ -1580,7 +1580,6 @@ static void fornum (LexState *ls, TString *varname, int line) { int base = fs->freereg; new_localvarliteral(ls, "(for state)"); new_localvarliteral(ls, "(for state)"); - new_localvarliteral(ls, "(for state)"); new_localvarkind(ls, varname, RDKCONST); /* control variable */ checknext(ls, '='); exp1(ls); /* initial value */ @@ -1592,7 +1591,8 @@ static void fornum (LexState *ls, TString *varname, int line) { luaK_int(fs, fs->freereg, 1); luaK_reserveregs(fs, 1); } - adjustlocalvars(ls, 3); /* control variables */ + adjustlocalvars(ls, 2); /* start scope for internal state variables */ + fs->freereg--; /* OP_FORPREP removes one register from the stack */ forbody(ls, base, line, 1, 0); } -- cgit v1.2.3-55-g6feb