Rev 4294: Fairly significant savings... avoid looking at self._last_recently_used. in lp:///~jameinel/bzr/1.15-lru-gc
John Arbash Meinel
john at arbash-meinel.com
Thu Apr 16 21:46:17 BST 2009
At lp:///~jameinel/bzr/1.15-lru-gc
------------------------------------------------------------
revno: 4294
revision-id: john at arbash-meinel.com-20090416204541-gg2qtfggaxwzudvz
parent: john at arbash-meinel.com-20090416203230-ltw57cs1yp0yp5q9
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 1.15-lru-gc
timestamp: Thu 2009-04-16 15:45:41 -0500
message:
Fairly significant savings... avoid looking at self._last_recently_used.
We can get the same information from node.next_key, which is a value we need anyway.
Somewhat surprisingly, this drops us from 7.6s => 7.1s on 2.8M lookups.
-------------- next part --------------
=== modified file 'bzrlib/lru_cache.py'
--- a/bzrlib/lru_cache.py 2009-04-16 20:32:30 +0000
+++ b/bzrlib/lru_cache.py 2009-04-16 20:45:41 +0000
@@ -88,15 +88,15 @@
return node.value
# Remove this node from the old location
node_prev = node.prev
- if node is self._last_recently_used:
- self._last_recently_used = node_prev
next_key = node.next_key
- node_prev.next_key = next_key
if next_key is None:
- node_next = None
+ # 'node' is the _last_recently_used, because it doesn't have a
+ # 'next' item. So move the current lru to the previous node.
+ self._last_recently_used = node_prev
else:
node_next = cache[next_key]
node_next.prev = node_prev
+ node_prev.next_key = next_key
# Insert this node at the front of the list
node.next_key = mru.key
mru.prev = node
More information about the bazaar-commits
mailing list