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.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user