Diff

util/events.lua @ 1417:b02b22f77326

util.events: Replaced ipairs with slightly faster numeric for loop - #optimization
author Waqas Hussain <waqas20@gmail.com>
date Fri, 26 Jun 2009 08:52:26 +0500
parent 1181:dffbb7d1da4b
child 1507:92357dffe743
line wrap: on
line diff
--- 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