New way to keep hints for table length
Instead of using 'alimit' for keeping the size of the array and at the same time being a hint for '#t', a table now keeps these two values separate. The Table structure has a field 'asize' with the size of the array, while the length hint is kept in the array itself. That way, tables with no array part waste no space with that field. Moreover, the space for the hint may have zero cost for small arrays, if the array of tags plus the hint still fits in a single word.
This commit is contained in:
2
lvm.c
2
lvm.c
@@ -1865,7 +1865,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
|
||||
pc++;
|
||||
}
|
||||
/* when 'n' is known, table should have proper size */
|
||||
if (last > luaH_realasize(h)) { /* needs more space? */
|
||||
if (last > h->asize) { /* needs more space? */
|
||||
/* fixed-size sets should have space preallocated */
|
||||
lua_assert(GETARG_vB(i) == 0);
|
||||
luaH_resizearray(L, h, last); /* preallocate it at once */
|
||||
|
||||
Reference in New Issue
Block a user