Rev 3903: Don't cache the InventoryEntry we will return, callers mutate those objects. in http://bzr.arbash-meinel.com/branches/bzr/1.11/xml_cache

John Arbash Meinel john at arbash-meinel.com
Thu Dec 11 22:34:55 GMT 2008


At http://bzr.arbash-meinel.com/branches/bzr/1.11/xml_cache

------------------------------------------------------------
revno: 3903
revision-id: john at arbash-meinel.com-20081211223447-wqyc0ynjs2w59r3s
parent: john at arbash-meinel.com-20081211222229-c9l7lebfgrzb5pme
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: xml_cache
timestamp: Thu 2008-12-11 16:34:47 -0600
message:
  Don't cache the InventoryEntry we will return, callers mutate those objects.
-------------- next part --------------
=== modified file 'bzrlib/xml8.py'
--- a/bzrlib/xml8.py	2008-12-11 20:09:19 +0000
+++ b/bzrlib/xml8.py	2008-12-11 22:34:47 +0000
@@ -468,7 +468,11 @@
             raise errors.UnsupportedInventoryKind(kind)
         ie.revision = revision
         if revision is not None:
-            self._entry_cache[key] = ie
+            # We cache a copy() because callers like to mutate objects, and
+            # that would cause the item in cache to mutate as well.
+            # This has a small effect on many-inventory performance, because
+            # the majority fraction is spent in cache hits, not misses.
+            self._entry_cache[key] = ie.copy()
 
         return ie
 



More information about the bazaar-commits mailing list