lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

ltable.c contains the following (5,1 beta, line 39):

** max size of array part is 2^MAXBITS
#define MAXBITS         26
#define MAXBITS         (LUAI_BITSINT-2)

#define MAXASIZE        (1 << MAXBITS)

This would appear to restrict the array part of a table to 64 million elements even on ILP64 architectures.

Clearly this does not affect the functionality of large tables; the extra elements would transparently be stored in the hash part (more or less transparently, anyway) but it seems like it would impose a hefty memory penalty in such cases.

On the other hand, if the Lua instance were compiled with lua_Number as a (single-precision) float, then the array part could grow to a larger size than could be represented as an integral lua_Number, which seems like it ought to trigger an error of some sort.

So why 26?