aboutsummaryrefslogtreecommitdiff
path: root/lparser.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2022-12-21 15:35:40 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2022-12-21 15:35:40 -0300
commit873588dc5f04bfc37006c3dc6ceb9a495ea503f2 (patch)
tree3d47594a73706e49cce5e814982607607cde45d7 /lparser.c
parentb2f7b3b79f3117885b265575f6c5dbf934757797 (diff)
downloadlua-873588dc5f04bfc37006c3dc6ceb9a495ea503f2.tar.gz
lua-873588dc5f04bfc37006c3dc6ceb9a495ea503f2.tar.bz2
lua-873588dc5f04bfc37006c3dc6ceb9a495ea503f2.zip
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.
Diffstat (limited to 'lparser.c')
-rw-r--r--lparser.c4
1 files changed, 2 insertions, 2 deletions
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) {
1580 int base = fs->freereg; 1580 int base = fs->freereg;
1581 new_localvarliteral(ls, "(for state)"); 1581 new_localvarliteral(ls, "(for state)");
1582 new_localvarliteral(ls, "(for state)"); 1582 new_localvarliteral(ls, "(for state)");
1583 new_localvarliteral(ls, "(for state)");
1584 new_localvarkind(ls, varname, RDKCONST); /* control variable */ 1583 new_localvarkind(ls, varname, RDKCONST); /* control variable */
1585 checknext(ls, '='); 1584 checknext(ls, '=');
1586 exp1(ls); /* initial value */ 1585 exp1(ls); /* initial value */
@@ -1592,7 +1591,8 @@ static void fornum (LexState *ls, TString *varname, int line) {
1592 luaK_int(fs, fs->freereg, 1); 1591 luaK_int(fs, fs->freereg, 1);
1593 luaK_reserveregs(fs, 1); 1592 luaK_reserveregs(fs, 1);
1594 } 1593 }
1595 adjustlocalvars(ls, 3); /* control variables */ 1594 adjustlocalvars(ls, 2); /* start scope for internal state variables */
1595 fs->freereg--; /* OP_FORPREP removes one register from the stack */
1596 forbody(ls, base, line, 1, 0); 1596 forbody(ls, base, line, 1, 0);
1597} 1597}
1598 1598