Rev 4295: (jam) Remove _LRUNode from the linked list as well as the dict. in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Thu Apr 16 16:25:04 BST 2009
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 4295
revision-id: pqm at pqm.ubuntu.com-20090416152500-83w2bul0hwhhm7gd
parent: pqm at pqm.ubuntu.com-20090415172601-buxpv8kc1qf9uork
parent: john at arbash-meinel.com-20090416020821-l02fxbqhx341yo8o
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Thu 2009-04-16 16:25:00 +0100
message:
(jam) Remove _LRUNode from the linked list as well as the dict.
modified:
bzrlib/lru_cache.py lru_cache.py-20070119165515-tlw203kuwh0id5gv-1
bzrlib/tests/test_lru_cache.py test_lru_cache.py-20070119165535-hph6rk4h9rzy4180-1
------------------------------------------------------------
revno: 4294.1.1
revision-id: john at arbash-meinel.com-20090416020821-l02fxbqhx341yo8o
parent: pqm at pqm.ubuntu.com-20090415172601-buxpv8kc1qf9uork
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: jam-integration
timestamp: Wed 2009-04-15 21:08:21 -0500
message:
When removing a node from an LRUCache, properly remove it from the linked list.
modified:
bzrlib/lru_cache.py lru_cache.py-20070119165515-tlw203kuwh0id5gv-1
bzrlib/tests/test_lru_cache.py test_lru_cache.py-20070119165535-hph6rk4h9rzy4180-1
=== modified file 'bzrlib/lru_cache.py'
--- a/bzrlib/lru_cache.py 2009-03-30 11:49:32 +0000
+++ b/bzrlib/lru_cache.py 2009-04-16 02:08:21 +0000
@@ -235,6 +235,14 @@
if self._last_recently_used is None:
self._most_recently_used = None
node.run_cleanup()
+ # Now remove this node from the linked list
+ if node.prev is not None:
+ node.prev.next = node.next
+ if node.next is not None:
+ node.next.prev = node.prev
+ # And remove this node's pointers
+ node.prev = None
+ node.next = None
def _remove_lru(self):
"""Remove one entry from the lru, and handle consequences.
=== modified file 'bzrlib/tests/test_lru_cache.py'
--- a/bzrlib/tests/test_lru_cache.py 2009-03-24 17:01:50 +0000
+++ b/bzrlib/tests/test_lru_cache.py 2009-04-16 02:08:21 +0000
@@ -138,6 +138,8 @@
# We hit the max
self.assertEqual(10, len(cache))
+ self.assertEqual([11, 10, 9, 1, 8, 7, 6, 5, 4, 3],
+ [n.key for n in cache._walk_lru()])
def test_cleanup_shrinks_to_after_clean_count(self):
cache = lru_cache.LRUCache(max_cache=5, after_cleanup_count=3)
More information about the bazaar-commits
mailing list