Make poezio.events more Cython-friendly.
This commit is contained in:
parent
840ad7433f
commit
08baecfc5a
1 changed files with 9 additions and 9 deletions
|
@ -55,10 +55,11 @@ class EventHandler(object):
|
||||||
if name not in self.events:
|
if name not in self.events:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
callbacks = self.events[name]
|
||||||
if position >= 0:
|
if position >= 0:
|
||||||
self.events[name].insert(position, callback)
|
callbacks.insert(position, callback)
|
||||||
else:
|
else:
|
||||||
self.events[name].append(callback)
|
callbacks.append(callback)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -77,11 +78,10 @@ class EventHandler(object):
|
||||||
Remove the callback from the list of callbacks of the given event
|
Remove the callback from the list of callbacks of the given event
|
||||||
"""
|
"""
|
||||||
if not name:
|
if not name:
|
||||||
for event in self.events:
|
for callbacks in self.events.values():
|
||||||
while callback in self.events[event]:
|
while callback in callbacks:
|
||||||
self.events[event].remove(callback)
|
callbacks.remove(callback)
|
||||||
return True
|
|
||||||
else:
|
else:
|
||||||
if callback in self.events[name]:
|
callbacks = self.events[name]
|
||||||
self.events[name].remove(callback)
|
if callback in callbacks:
|
||||||
|
callbacks.remove(callback)
|
||||||
|
|
Loading…
Reference in a new issue