Question about table arrays
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Question about table arrays
- From: Rici Lake <lua@...>
- Date: Mon, 9 Jan 2006 11:09:32 -0500
ltable.c contains the following (5,1 beta, line 39):
/*
** max size of array part is 2^MAXBITS
*/
#if LUAI_BITSINT > 26
#define MAXBITS 26
#else
#define MAXBITS (LUAI_BITSINT-2)
#endif
#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?