|
I'm not sure if I have seen this documented although I know that Lua
has optimization for tables used as arrays. But I didn't expect that
would be due to using dot notation. How can this be? local a = {} for i = 1, arg[1] do a[i] = i * i end DOC:/u/doc/lua: >time lua lbench1.lua 2000000 real 0m 0.35s user 0m 0.18s sys 0m 0.06s local a = {} for i = 1, arg[1] do a.i = i * i end DOC:/u/doc/lua: >time lua lbench1.lua 2000000 real 0m 0.19s user 0m 0.12s sys 0m 0.04s |