summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>2015-11-26 02:35:20 +0000
committerEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>2016-06-11 20:49:46 +0100
commit08baecfc5ab40d90622fe789a93aedd41ca3b178 (patch)
tree79997b5990dce5f66a2be06eeb9198861c87c6f3
parent840ad7433f1c0e8005478fbb241b13d3a5b7b6e7 (diff)
downloadpoezio-08baecfc5ab40d90622fe789a93aedd41ca3b178.tar.gz
poezio-08baecfc5ab40d90622fe789a93aedd41ca3b178.tar.bz2
poezio-08baecfc5ab40d90622fe789a93aedd41ca3b178.tar.xz
poezio-08baecfc5ab40d90622fe789a93aedd41ca3b178.zip
Make poezio.events more Cython-friendly.
-rw-r--r--poezio/events.py18
1 files changed, 9 insertions, 9 deletions
diff --git a/poezio/events.py b/poezio/events.py
index 15ef3e35..97d77626 100644
--- a/poezio/events.py
+++ b/poezio/events.py
@@ -55,10 +55,11 @@ class EventHandler(object):
if name not in self.events:
return False
+ callbacks = self.events[name]
if position >= 0:
- self.events[name].insert(position, callback)
+ callbacks.insert(position, callback)
else:
- self.events[name].append(callback)
+ callbacks.append(callback)
return True
@@ -77,11 +78,10 @@ class EventHandler(object):
Remove the callback from the list of callbacks of the given event
"""
if not name:
- for event in self.events:
- while callback in self.events[event]:
- self.events[event].remove(callback)
- return True
+ for callbacks in self.events.values():
+ while callback in callbacks:
+ callbacks.remove(callback)
else:
- if callback in self.events[name]:
- self.events[name].remove(callback)
-
+ callbacks = self.events[name]
+ if callback in callbacks:
+ callbacks.remove(callback)