util.events: Replaced ipairs with slightly faster numeric for loop - #optimization

Fri, 26 Jun 2009 08:52:26 +0500

author
Waqas Hussain <waqas20@gmail.com>
date
Fri, 26 Jun 2009 08:52:26 +0500
changeset 1417
b02b22f77326
parent 1416
f916f0ff90e5
child 1418
d14de6cb8b5b

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

mercurial