~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/lru_cache.py

  • Committer: John Arbash Meinel
  • Date: 2009-04-16 20:32:30 UTC
  • mto: This revision was merged to the branch mainline in revision 4323.
  • Revision ID: john@arbash-meinel.com-20090416203230-ltw57cs1yp0yp5q9
Remove the double getattr() for self._cache.
The common case is that prev and next both exist, so tweak for that case.

Show diffs side-by-side

added added

removed removed

Lines of Context:
76
76
        return key in self._cache
77
77
 
78
78
    def __getitem__(self, key):
79
 
        node = self._cache[key]
 
79
        cache = self._cache
 
80
        node = cache[key]
80
81
        # Inlined from _record_access to decrease the overhead of __getitem__
81
82
        # We also have more knowledge about structure if __getitem__ is
82
83
        # succeeding, then we know that self._most_recently_used must not be
94
95
        if next_key is None:
95
96
            node_next = None
96
97
        else:
97
 
            node_next = self._cache[next_key]
 
98
            node_next = cache[next_key]
98
99
            node_next.prev = node_prev
99
100
        # Insert this node at the front of the list
100
101
        node.next_key = mru.key