Rev 5052: (jam) Small tweaks to the move-to-front algo, allowing shortcuts, etc. in file:///home/pqm/archives/thelove/bzr/2.2/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Wed Apr 14 09:41:34 BST 2010


At file:///home/pqm/archives/thelove/bzr/2.2/

------------------------------------------------------------
revno: 5052 [merge]
revision-id: pqm at pqm.ubuntu.com-20100414084133-ka1xi7y837y85x85
parent: pqm at pqm.ubuntu.com-20100414061047-7agrys15hfjrmm9h
parent: john at arbash-meinel.com-20100414050653-5l0z0hn2pk2y2uf5
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: 2.2
timestamp: Wed 2010-04-14 09:41:33 +0100
message:
  (jam) Small tweaks to the move-to-front algo, allowing shortcuts, etc.
modified:
  bzrlib/index.py                index.py-20070712131115-lolkarso50vjr64s-1
=== modified file 'bzrlib/index.py'
--- a/bzrlib/index.py	2010-04-14 04:26:53 +0000
+++ b/bzrlib/index.py	2010-04-14 05:06:53 +0000
@@ -1435,19 +1435,27 @@
         if 'index' in debug.debug_flags:
             mutter('CombinedGraphIndex reordering: currently %r, promoting %r',
                    indices_info, hit_indices)
-        hit_indices_info = []
         hit_names = []
-        unhit_indices_info = []
-        for name, idx in indices_info:
+        unhit_names = []
+        new_hit_indices = []
+        unhit_indices = []
+
+        for offset, (name, idx) in enumerate(indices_info):
             if idx in hit_indices:
-                info = hit_indices_info
                 hit_names.append(name)
+                new_hit_indices.append(idx)
+                if len(new_hit_indices) == len(hit_indices):
+                    # We've found all of the hit entries, everything else is
+                    # unhit
+                    unhit_names.extend(self._index_names[offset+1:])
+                    unhit_indices.extend(self._indices[offset+1:])
+                    break
             else:
-                info = unhit_indices_info
-            info.append((name, idx))
-        final_info = hit_indices_info + unhit_indices_info
-        self._indices = [idx for (name, idx) in final_info]
-        self._index_names = [name for (name, idx) in final_info]
+                unhit_names.append(name)
+                unhit_indices.append(idx)
+
+        self._indices = new_hit_indices + unhit_indices
+        self._index_names = hit_names + unhit_names
         if 'index' in debug.debug_flags:
             mutter('CombinedGraphIndex reordered: %r', self._indices)
         return hit_names




More information about the bazaar-commits mailing list