lua-users home
lua-l archive

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


Roberto wrote:

(I am not claiming this is useful for any particular task;
I am only showing that not creating a new closure is not
an optimization: it changes the semantics of the
language.)

Do-nothing functions can be used as gensyms (unique values).
They are a slightly faster to create than empty tables:

$ time lua -e 't={} for i=1,999999 do t[i]={}end'

real    0m5.453s
user    0m5.249s
sys     0m0.124s
$ time lua -e 't={} for i=1,999999 do t[i]=function()end end'

real    0m3.172s
user    0m2.890s
sys     0m0.170s

--
Aaron
http://arundelo.com/