Rev 4293: Remove the double getattr() for self._cache. in lp:///~jameinel/bzr/1.15-lru-gc

John Arbash Meinel john at arbash-meinel.com
Thu Apr 16 21:33:06 BST 2009


At lp:///~jameinel/bzr/1.15-lru-gc

------------------------------------------------------------
revno: 4293
revision-id: john at arbash-meinel.com-20090416203230-ltw57cs1yp0yp5q9
parent: john at arbash-meinel.com-20090416195528-bb69o9sepyh0fmk8
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 1.15-lru-gc
timestamp: Thu 2009-04-16 15:32:30 -0500
message:
  Remove the double getattr() for self._cache.
  The common case is that prev and next both exist, so tweak for that case.
-------------- next part --------------
=== modified file 'bzrlib/lru_cache.py'
--- a/bzrlib/lru_cache.py	2009-04-16 19:55:28 +0000
+++ b/bzrlib/lru_cache.py	2009-04-16 20:32:30 +0000
@@ -76,7 +76,8 @@
         return key in self._cache
 
     def __getitem__(self, key):
-        node = self._cache[key]
+        cache = self._cache
+        node = cache[key]
         # Inlined from _record_access to decrease the overhead of __getitem__
         # We also have more knowledge about structure if __getitem__ is
         # succeeding, then we know that self._most_recently_used must not be
@@ -94,7 +95,7 @@
         if next_key is None:
             node_next = None
         else:
-            node_next = self._cache[next_key]
+            node_next = cache[next_key]
             node_next.prev = node_prev
         # Insert this node at the front of the list
         node.next_key = mru.key



More information about the bazaar-commits mailing list