Fri, 26 Jun 2009 08:52:26 +0500
util.events: Replaced ipairs with slightly faster numeric for loop - #optimization
util/events.lua | file | annotate | diff | comparison | revisions |
--- a/util/events.lua Thu Jun 25 17:22:53 2009 +0500 +++ b/util/events.lua Fri Jun 26 08:52:26 2009 +0500 @@ -53,8 +53,8 @@ local h = handlers[event]; if not h then h = {}; handlers[event] = h; end local dispatcher = function(...) - for _, handler in ipairs(h) do - local ret = handler(...); + for i=1,#h do + local ret = h[i](...); if ret ~= nil then return ret; end end end; @@ -67,8 +67,8 @@ local function fire_event(event, ...) -- FIXME duplicates dispatcher code local h = handlers[event]; if h then - for _, handler in ipairs(h) do - local ret = handler(...); + for i=1,#h do + local ret = h[i](...); if ret ~= nil then return ret; end end end