~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/graph.py

  • Committer: John Arbash Meinel
  • Date: 2009-06-08 21:56:25 UTC
  • mto: (4371.4.5 vila-better-heads)
  • mto: This revision was merged to the branch mainline in revision 4449.
  • Revision ID: john@arbash-meinel.com-20090608215625-dnc3fzepsc2d4nkj
Avoiding set operations when the ancestor_of field is the same helps quite a bit.

Now down to 0.65:1

Show diffs side-by-side

added added

removed removed

Lines of Context:
1392
1392
        nodes = self._nodes
1393
1393
        heappop = heapq.heappop
1394
1394
        heappush = heapq.heappush
 
1395
        def combine_parents(one, two):
 
1396
            all_ancestors = set(one)
 
1397
            all_ancestors.update(two)
 
1398
            return tuple(sorted(all_ancestors))
1395
1399
        while queue and len(candidate_nodes) > 1:
1396
1400
            counters[0] += 1
1397
1401
            _, next = heappop(queue)
1443
1447
                    else:
1444
1448
                        counters[3] += 1
1445
1449
                        # Combine to get the full set of parents
1446
 
                        def combine_parents():
1447
 
                            all_ancestors = set(ancestor_of)
1448
 
                            all_ancestors.update(next_ancestor_of)
1449
 
                            return tuple(all_ancestors)
1450
 
                        parent_node.ancestor_of = combine_parents()
 
1450
                        if ancestor_of != next_ancestor_of:
 
1451
                            parent_node.ancestor_of = combine_parents(
 
1452
                                ancestor_of, next_ancestor_of)
1451
1453
                        # This would otherwise require popping the item out of the
1452
1454
                        # queue, because we think we are done processing it.
1453
1455
                        # As is, we'll just let the queue clean itself up