lua-users home
lua-l archive

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

on 12/1/05 1:19 PM, Roberto Ierusalimschy at 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.