lua-users home
lua-l archive

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

Aaron Brown <arundelo <at>> writes:
> 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

and only slightly-slightly (~10%) faster than newproxy (userdata):

$ time lua -e 't={} local newproxy=newproxy; for i=1,999999 do t[i]=newproxy()
end '