From 6eb53b752617fae9e1329bfe2cfecdcbb593c398 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Thu, 27 Feb 2020 12:59:22 -0300 Subject: Details Several details in code (e.g., moving a variable to the most inner scope that encloses its uses), comments, parameter names, extra tests. --- lcode.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'lcode.c') diff --git a/lcode.c b/lcode.c index 35e0527f..83a6d064 100644 --- a/lcode.c +++ b/lcode.c @@ -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); } -- cgit v1.2.3-55-g6feb