lua-users home
lua-l archive

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


> > There is a memory penalty. When the start index moves away from 1,
> > Lua will stop storing these entries as array entries and start
> > storing them as hash entries. That roughly doubles the memory used
> > by the table.
> 
> [...] Still, it would appear strange that using 0 would double the
> memory used by the table: wouldn't it be sufficient to hash just 0 and
> use the array method for all the other consecutive entries? [...]

This is what Lua does. Using 0 does not double the memory used by the
table. The problem is "When the start index moves away from 1"; for
instance, when the list elements are between 302 and 341. Then Lua will
not keep an array with at least 341 entries to use only 40 of them.

-- Roberto