Several details in code (e.g., moving a variable to the most inner
scope that encloses its uses), comments, parameter names, extra tests.
This commit is contained in:
Roberto Ierusalimschy
2020-02-27 12:59:22 -03:00
parent 9b7987a9d1
commit 6eb53b7526
13 changed files with 52 additions and 45 deletions

15
lcode.c
View File

@@ -1730,17 +1730,12 @@ void luaK_fixline (FuncState *fs, int line) {
}
void luaK_settablesize (FuncState *fs, int pc, int ra, int rc, int rb) {
void luaK_settablesize (FuncState *fs, int pc, int ra, int asize, int hsize) {
Instruction *inst = &fs->f->code[pc];
int extra = 0;
int k = 0;
if (rb != 0)
rb = luaO_ceillog2(rb) + 1; /* hash size */
if (rc > MAXARG_C) { /* does it need the extra argument? */
extra = rc / (MAXARG_C + 1);
rc %= (MAXARG_C + 1);
k = 1;
}
int rb = (hsize != 0) ? luaO_ceillog2(hsize) + 1 : 0; /* hash size */
int extra = asize / (MAXARG_C + 1); /* higher bits of array size */
int rc = asize % (MAXARG_C + 1); /* lower bits of array size */
int k = (extra > 0); /* true iff needs extra argument */
*inst = CREATE_ABCk(OP_NEWTABLE, ra, rb, rc, k);
*(inst + 1) = CREATE_Ax(OP_EXTRAARG, extra);
}