Rev 2925: Documentation to aid our failing memory in the future. in http://people.ubuntu.com/~robertc/baz2.0/dirstate.cache

Robert Collins robertc at robertcollins.net
Mon Oct 22 21:05:20 BST 2007


At http://people.ubuntu.com/~robertc/baz2.0/dirstate.cache

------------------------------------------------------------
revno: 2925
revision-id:robertc at robertcollins.net-20071022200512-ev362dzjjoj9v7r1
parent: robertc at robertcollins.net-20071022195941-06a7tdtkd8muueg9
committer: Robert Collins <robertc at robertcollins.net>
branch nick: dirstate.cache
timestamp: Tue 2007-10-23 06:05:12 +1000
message:
  Documentation to aid our failing memory in the future.
modified:
  bzrlib/dirstate.py             dirstate.py-20060728012006-d6mvoihjb3je9peu-1
=== modified file 'bzrlib/dirstate.py'
--- a/bzrlib/dirstate.py	2007-10-22 19:59:41 +0000
+++ b/bzrlib/dirstate.py	2007-10-22 20:05:12 +0000
@@ -345,6 +345,10 @@
             self._sha1_file = self._sha1_file_and_mutter
         else:
             self._sha1_file = osutils.sha_file_by_name
+        # These two attributes provide a simple cache for lookups into the
+        # dirstate in-memory vectors. By probing respectively for the last
+        # block, and for the next entry, we save nearly 2 bisections per path
+        # during commit.
         self._last_block_index = None
         self._last_entry_index = None
 
@@ -1061,6 +1065,7 @@
         present = (block_index < len(self._dirblocks) and
             self._dirblocks[block_index][0] == key[0])
         self._last_block_index = block_index
+        # Reset the entry index cache to the beginning of the block.
         self._last_entry_index = -1
         return block_index, present
 



More information about the bazaar-commits mailing list