[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: array index and modulo
- From: David Kastrup <dak@...>
- Date: Sat, 31 Mar 2007 07:45:46 +0200
roberto@inf.puc-rio.br (Roberto Ierusalimschy) writes:
>> > 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.
Ok, then I misunderstood that comment.
> 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.
Thanks.
--
David Kastrup, Kriemhildstr. 15, 44793 Bochum