aboutsummaryrefslogtreecommitdiff
path: root/lvm.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2024-11-29 17:26:20 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2024-11-29 17:26:20 -0300
commit002beeebe79065e03dd9f531bee367e8459e3f64 (patch)
tree5b066d30e08950c923c253ce85f702b39fbe9c31 /lvm.c
parent9329eeac3b7035c223d7a8b63dbde1f6db371bf5 (diff)
downloadlua-002beeebe79065e03dd9f531bee367e8459e3f64.tar.gz
lua-002beeebe79065e03dd9f531bee367e8459e3f64.tar.bz2
lua-002beeebe79065e03dd9f531bee367e8459e3f64.zip
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.
Diffstat (limited to 'lvm.c')
-rw-r--r--lvm.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/lvm.c b/lvm.c
index 33da5609..1c564a71 100644
--- a/lvm.c
+++ b/lvm.c
@@ -1865,7 +1865,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
1865 pc++; 1865 pc++;
1866 } 1866 }
1867 /* when 'n' is known, table should have proper size */ 1867 /* when 'n' is known, table should have proper size */
1868 if (last > luaH_realasize(h)) { /* needs more space? */ 1868 if (last > h->asize) { /* needs more space? */
1869 /* fixed-size sets should have space preallocated */ 1869 /* fixed-size sets should have space preallocated */
1870 lua_assert(GETARG_vB(i) == 0); 1870 lua_assert(GETARG_vB(i) == 0);
1871 luaH_resizearray(L, h, last); /* preallocate it at once */ 1871 luaH_resizearray(L, h, last); /* preallocate it at once */