From d9a71da2205b437903f52f517e3c6bc72eebd59a Mon Sep 17 00:00:00 2001 From: Waqas Hussain Date: Fri, 26 Jun 2009 08:52:26 +0500 Subject: util.events: Replaced ipairs with slightly faster numeric for loop - #optimization --- util/events.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/util/events.lua b/util/events.lua index 3816f30b..6d69c95d 100644 --- a/util/events.lua +++ b/util/events.lua @@ -53,8 +53,8 @@ function new() 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 @@ function new() 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 -- cgit v1.2.3