From 002beeebe79065e03dd9f531bee367e8459e3f64 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Fri, 29 Nov 2024 17:26:20 -0300 Subject: 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. --- lvm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lvm.c') 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) { 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 */ -- cgit v1.2.3-55-g6feb