~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/index.py

  • Committer: John Arbash Meinel
  • Date: 2010-04-14 05:04:01 UTC
  • mto: (5050.3.2 2.2)
  • mto: This revision was merged to the branch mainline in revision 5157.
  • Revision ID: john@arbash-meinel.com-20100414050401-35jjdm3sl27far7t
Avoid packing and unpacking the indices, and shortcut once you've found all 
the interesting indices.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1431
1431
        
1432
1432
        Returns a list of names corresponding to the hit_indices param.
1433
1433
        """
1434
 
        indices_info = zip(self._index_names, self._indices)
1435
1434
        if 'index' in debug.debug_flags:
1436
1435
            mutter('CombinedGraphIndex reordering: currently %r, promoting %r',
1437
1436
                   indices_info, hit_indices)
1438
 
        hit_indices_info = []
1439
1437
        hit_names = []
1440
 
        unhit_indices_info = []
1441
 
        for name, idx in indices_info:
 
1438
        unhit_names = []
 
1439
        new_hit_indices = []
 
1440
        unhit_indices = []
 
1441
 
 
1442
        for offset, (name, idx) in enumerate(zip(self._index_names,
 
1443
                                                 self._indices)):
1442
1444
            if idx in hit_indices:
1443
 
                info = hit_indices_info
 
1445
                new_hit_indices.append(idx)
1444
1446
                hit_names.append(name)
 
1447
                if len(new_hit_indices) == len(hit_indices):
 
1448
                    # We've found all of the hit entries, everything else is
 
1449
                    # unhit
 
1450
                    unhit_names.extend(self._index_names[offset+1:])
 
1451
                    unhit_indices.extend(self._indices[offset+1:])
 
1452
                    break
1445
1453
            else:
1446
 
                info = unhit_indices_info
1447
 
            info.append((name, idx))
1448
 
        final_info = hit_indices_info + unhit_indices_info
1449
 
        self._indices = [idx for (name, idx) in final_info]
1450
 
        self._index_names = [name for (name, idx) in final_info]
 
1454
                unhit_names.append(name)
 
1455
                unhit_indices.append(idx)
 
1456
 
 
1457
        self._indices = new_hit_indices + unhit_indices
 
1458
        self._index_names = hit_names + unhit_names
1451
1459
        if 'index' in debug.debug_flags:
1452
1460
            mutter('CombinedGraphIndex reordered: %r', self._indices)
1453
1461
        return hit_names