Changeset

3776:bc4f67a0658d

util.events: Remove an event's table when it has no more handlers.
author Waqas Hussain <waqas20@gmail.com>
date Sun, 19 Dec 2010 00:53:19 +0500
parents 3775:f3f2a7810108
children 3779:fb1d2e5a2fc9
files util/events.lua
diffstat 1 files changed, 3 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/util/events.lua	Sat Dec 18 14:46:28 2010 +0000
+++ b/util/events.lua	Sun Dec 19 00:53:19 2010 +0500
@@ -45,6 +45,9 @@
 		if map then
 			map[handler] = nil;
 			handlers[event] = nil;
+			if next(map) == nil then
+				event_map[event] = nil;
+			end
 		end
 	end;
 	local function add_handlers(handlers)