lua-users home
lua-l archive

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


From: "Nick Davies" <goodbytes@binarysurge.com>
> I'm not actually going to have that many triggers in a room. Like... one
> would be above average. Two would be like... holy cow.

heheh, but still designing it to be expandable instead of designing it just
to fit the current capabilities might be to your advantage later.

> The 'indexing globals as locals' thing was pretty much a quick fix, so I
> just thought I'd try it out.

I'd guess that a global like "Audio.PlayTrack" from within a function would
require 3 table lookups, one to hit the local scope (which would usually be
empty and therefore probably a negligible speed hit), then the global scope
(which would find "Audio"), then search "Audio" for "PlayTrack".  Making
"Audio" local would remove a very small portion of the search time, unless
your function has tons of locals anyway.

For the least searches, you should hold on to the function "PlayTrack" as a
local, instead of "Audio".  I don't know if upvalues are faster than normal
locals, but you could mess around with those if you haven't already and see
how fast they are in comparison.  I'd suggest simply timing a loop where you
call something 10,000 times in various ways and see which one executes
fastest. :)