Rev 3893: Handle that Python2.4 doesn't have collections.deque.remove in http://bzr.arbash-meinel.com/branches/bzr/1.11/fifo_cache
John Arbash Meinel
john at arbash-meinel.com
Wed Dec 10 00:07:53 GMT 2008
At http://bzr.arbash-meinel.com/branches/bzr/1.11/fifo_cache
------------------------------------------------------------
revno: 3893
revision-id: john at arbash-meinel.com-20081210000733-5h1j6enwe37ymnuj
parent: john at arbash-meinel.com-20081209222640-u3iece2ixcd0q7lj
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: fifo_cache
timestamp: Tue 2008-12-09 18:07:33 -0600
message:
Handle that Python2.4 doesn't have collections.deque.remove
-------------- next part --------------
=== modified file 'bzrlib/fifo_cache.py'
--- a/bzrlib/fifo_cache.py 2008-12-09 22:26:40 +0000
+++ b/bzrlib/fifo_cache.py 2008-12-10 00:07:33 +0000
@@ -39,7 +39,16 @@
def __delitem__(self, key):
# Remove the key from an arbitrary location in the queue
- self._queue.remove(key)
+ remove = getattr(self._queue, 'remove', None)
+ # Python2.5's has deque.remove, but Python2.4 does not
+ if remove is not None:
+ remove(key)
+ else:
+ # TODO: It would probably be faster to pop()/popleft() until we get to the
+ # key, and then insert those back into the queue. We know
+ # the key should only be present in one position, and we
+ # wouldn't need to rebuild the whole queue.
+ self._queue = deque([k for k in self._queue if k != key])
self._remove(key)
def add(self, key, value, cleanup=None):
More information about the bazaar-commits
mailing list