Commented a possible optimization.

This commit is contained in:
Jeremy Fincher 2004-04-13 00:12:23 +00:00
parent 7f6c401e74
commit 7aa35058f7

View File

@ -93,6 +93,11 @@ class Schedule(drivers.IrcDriver):
"""Removes the event with the given name from the schedule.""" """Removes the event with the given name from the schedule."""
del self.events[name] del self.events[name]
self.schedule = [(t, n) for (t, n) in self.schedule if n != name] self.schedule = [(t, n) for (t, n) in self.schedule if n != name]
# We must heapify here because the heap property may not be preserved
# by the above list comprehension. We could, conceivably, just mark
# the elements of the heap as removed and ignore them when we heappop,
# but that would only save a constant factor (we're already linear for
# the listcomp) so I'm not worried about it right now.
heapq.heapify(self.schedule) heapq.heapify(self.schedule)
def addPeriodicEvent(self, f, t, name=None): def addPeriodicEvent(self, f, t, name=None):