lua-users home
lua-l archive

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

2012/6/21 Michal Kottman <>:
> getmetatable("").__index = function(s, i)
>  if type(i) == "number" then
>   return string.sub(s, i, i)
>  else
>   return string[i]
>  end
> end

If I put string, sub and type in locals, the performance on my machine
was noticeably better. Without locals: 5.6, with locals: 4.06. Of
course, LuaJIT ran within 0.01 seconds (my os.time() has very low