Rev 5152: Avoid reordering when unnecessary. Fixes bug #562429 in http://bazaar.launchpad.net/~jameinel/bzr/2.2-move-to-front-if-changed-562429

John Arbash Meinel john at arbash-meinel.com
Wed Apr 14 05:27:09 BST 2010


At http://bazaar.launchpad.net/~jameinel/bzr/2.2-move-to-front-if-changed-562429

------------------------------------------------------------
revno: 5152
revision-id: john at arbash-meinel.com-20100414042653-gpn4fv8ahpb4x7gv
parent: pqm at pqm.ubuntu.com-20100413091953-ow6ds0g52xn734v5
fixes bug(s): https://launchpad.net/bugs/562429
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 2.2-move-to-front-if-changed-562429
timestamp: Tue 2010-04-13 23:26:53 -0500
message:
  Avoid reordering when unnecessary. Fixes bug #562429
  
  The existing code would do a full iteration over all pack indexes (for all of
  rix/iix/tix/cix/six), just to generate a list that was in the same order.
  Instead, we now only trigger a re-order when we know something has
  changed in the local index.
-------------- next part --------------
=== modified file 'NEWS'
--- a/NEWS	2010-04-13 09:19:53 +0000
+++ b/NEWS	2010-04-14 04:26:53 +0000
@@ -63,6 +63,10 @@
   read calls.  An incremental pull via plain HTTP takes half the time and
   bytes for a moderately large repository.  (Andrew Bennetts)
 
+* Index lookups only re-order the indexes when the hit files aren't
+  already first. Reduces the cost of reordering
+  (John Arbash Meinel, #562429)
+
 * Less code is loaded at startup.  (Cold-cache start time is about 10-20%
   less.)
   (Martin Pool, #553017)

=== modified file 'bzrlib/index.py'
--- a/bzrlib/index.py	2010-04-08 07:01:10 +0000
+++ b/bzrlib/index.py	2010-04-14 04:26:53 +0000
@@ -1418,6 +1418,10 @@
         _move_to_front propagates to all objects in self._sibling_indices by
         calling _move_to_front_by_name.
         """
+        if self._indices[:len(hit_indices)] == hit_indices:
+            # The 'hit_indices' are already at the front (and in the same
+            # order), no need to re-order
+            return
         hit_names = self._move_to_front_by_index(hit_indices)
         for sibling_idx in self._sibling_indices:
             sibling_idx._move_to_front_by_name(hit_names)



More information about the bazaar-commits mailing list