lua-users home
lua-l archive

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


On Wed, Dec 1, 2010 at 8:53 PM, Lorenzo Donati
<lorenzodonatibz@interfree.it> wrote:
> Pierre-Yves Gérardy wrote:
>>
>> Following the floating point discussion, I tried to look for a compilation
>> of the various gotchas Lua beginners encounter, but I couldn't find one, so
>> I decided to compile one...
>>
>
> Very commendable initiative! :-)
>
> If these could be considered gotchas:
>
> 1. I discovered "late in the game" that the most efficient way to append an
> item to an array was
> a[#a+1]=item
> and not
> table.insert(a,item)

Strictly speaking, isn't the fastest method:

local tbl = {}
local c = 0
c = c + 1
tbl[c] = item

It's a micro benchmark, but I believe this was the winner.

- Jim