[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: can someone explain why...
- From: Michal Kolodziejczyk <miko@...>
- Date: Thu, 07 Oct 2010 14:40:31 +0200
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%.
Well,
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:
http://www.lua.org/manual/5.1/manual.html#lua_createtable
> 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
slow:
http://luajit.org/
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).
Regards,
miko