diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-07-12 16:13:50 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-07-12 16:13:50 -0300 |
commit | 1fb4d539254b67e7e35ed698250c66d1edff0e08 (patch) | |
tree | 8f48b7ca736a7fb02834bcfac1415cd43307f529 /lvm.c | |
parent | f6aab3ec1f111cd8d968bdcb7ca800e93b819d24 (diff) | |
download | lua-1fb4d539254b67e7e35ed698250c66d1edff0e08.tar.gz lua-1fb4d539254b67e7e35ed698250c66d1edff0e08.tar.bz2 lua-1fb4d539254b67e7e35ed698250c66d1edff0e08.zip |
OP_NEWTABLE keeps exact size of arrays
OP_NEWTABLE is followed by an OP_EXTRAARG, so that it can keep
the exact size of the array part of the table to be created.
(Functions 'luaO_int2fb'/'luaO_fb2int' were removed.)
Diffstat (limited to '')
-rw-r--r-- | lvm.c | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -1250,11 +1250,15 @@ void luaV_execute (lua_State *L, CallInfo *ci) { | |||
1250 | int b = GETARG_B(i); | 1250 | int b = GETARG_B(i); |
1251 | int c = GETARG_C(i); | 1251 | int c = GETARG_C(i); |
1252 | Table *t; | 1252 | Table *t; |
1253 | c = (c == 0) ? 0 : 1 << (c - 1); /* size is 2^c */ | ||
1254 | if (b >= LIMTABSZ) | ||
1255 | b += LFIELDS_PER_FLUSH * GETARG_Ax(*pc) - LIMTABSZ; | ||
1256 | pc++; /* skip extra argument */ | ||
1253 | L->top = ci->top; /* correct top in case of GC */ | 1257 | L->top = ci->top; /* correct top in case of GC */ |
1254 | t = luaH_new(L); /* memory allocation */ | 1258 | t = luaH_new(L); /* memory allocation */ |
1255 | sethvalue2s(L, ra, t); | 1259 | sethvalue2s(L, ra, t); |
1256 | if (b != 0 || c != 0) | 1260 | if (b != 0 || c != 0) |
1257 | luaH_resize(L, t, luaO_fb2int(b), luaO_fb2int(c)); /* idem */ | 1261 | luaH_resize(L, t, b, c); /* idem */ |
1258 | checkGC(L, ra + 1); | 1262 | checkGC(L, ra + 1); |
1259 | vmbreak; | 1263 | vmbreak; |
1260 | } | 1264 | } |