At http://bzr.arbash-meinel.com/branches/bzr/1.11/lru_cache
------------------------------------------------------------
revno: 3884
revision-id: [EMAIL PROTECTED]
parent: [EMAIL PROTECTED]
committer: John Arbash Meinel <[EMAIL PROTECTED]>
branch nick: lru_cache
timestamp: Tue 2008-12-09 16:31:56 -0600
message:
Only cache cleanup functions if they aren't None.
=== modified file 'bzrlib/lru_cache.py'
--- a/bzrlib/lru_cache.py 2008-12-08 18:23:00 +0000
+++ b/bzrlib/lru_cache.py 2008-12-09 22:31:56 +0000
@@ -63,7 +63,8 @@
if key in self._cache:
self._remove(key)
self._cache[key] = value
- self._cleanup[key] = cleanup
+ if cleanup is not None:
+ self._cleanup[key] = cleanup
self._record_access(key)
if len(self._cache) > self._max_cache:
@@ -129,7 +130,7 @@
def _remove(self, key):
"""Remove an entry, making sure to maintain the invariants."""
- cleanup = self._cleanup.pop(key)
+ cleanup = self._cleanup.pop(key, None)
val = self._cache.pop(key)
if cleanup is not None:
cleanup(key, val)
@@ -223,7 +224,8 @@
return
self._value_size += value_len
self._cache[key] = value
- self._cleanup[key] = cleanup
+ if cleanup is not None:
+ self._cleanup[key] = cleanup
self._record_access(key)
if self._value_size > self._max_size:
--
bazaar-commits mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/bazaar-commits