Changeset

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
parents 1416:f916f0ff90e5
children 1418:d14de6cb8b5b
files util/events.lua
diffstat 1 files changed, 4 insertions(+), 4 deletions(-) [+]
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