[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: need help: some features of Lua don't fit well together
- From: Javier Guerra Giraldez <javier@...>
- Date: Tue, 14 Apr 2015 16:24:09 -0500
On Tue, Apr 14, 2015 at 3:46 PM, Aapo Talvensaari
<aapo.talvensaari@gmail.com> wrote:
> typedef struct Table {
> CommonHeader;
> lu_byte flags; /* 1<<p means tagmethod(p) is not present */
> lu_byte lsizenode; /* log2 of size of 'node' array */
> unsigned int sizearray; /* size of 'array' array */
> TValue *array; /* array part */
> Node *node;
> Node *lastfree; /* any free position is before this position */
> struct Table *metatable;
> GCObject *gclist;
> } Table;
that "array part" is an optimization that holds _some_ values, but
it's not guaranteed that all integer keys are stored there.
for example: if you define t={[1000000]=true} it's quite likely that
you will have an empty array part. if you start adding values with
keys between 1..999999, at some point you will have some of them in
the array part and some in the hash part. when you finally fill it
and you have all consecutive integer keys, you still might have a
sizable portion of them as hash entries.... or maybe not.
--
Javier