[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Counts, #, getn, etc
- From: Mark Hamburg <mhamburg@...>
- Date: Thu, 01 Dec 2005 16:13:41 -0800
on 12/1/05 1:19 PM, Roberto Ierusalimschy at firstname.lastname@example.org wrote:
>> Am I missing something or has table.insert( t, v ) gotten less efficient in
>> Lua 5.1 for repeated insertions because of the need to do a log n search of
>> the table each time to find the end of the table?
> Do you have figures?
Not yet. I was just looking at code and observing that each insert would do
a binary search to find the length if I was reading the code correctly.
Maybe an optimization to track when the array is known dense is in order?
But yes, I should follow up with code. I guess it's entirely possible that
one can binary search the array faster than a couple table lookups to find
the cached value for getn. And, of course, if getn wasn't caching before,
then I'm entirely off base in this concern.