lua-users home
lua-l archive

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

On 07.10.2010 10:57, Thierry wrote:

> To speed it up a bit, I did replace  :
>   local t =  {}
> by
>   local t = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
> I gain around 20%.

there was a proposal for using something like:

local t = table.create(initialListSize, initialHashSize)

but it is not there, because (I suppose) the lua programmer should not
worry about specific lua implementation (which could change some day).

If you really want to, there is similar API in C, so you could make a
small lua module:

> Can you comment or give me better ways to optimize this kind of scripts
> please, spare me writing this in C :)

Don't optimize your lua code, just use luajit if lua interpreter is too

You can spend too much time "optimizing", and with luajit it would be
still faster without

(Of course "don't optimize" means "don't use implementation specific
hack", but you still should use efficient algorithms).