From 8a9384617f20e91aab2ab50aee605f9f80744dc1 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Mon, 19 Feb 2007 06:35:02 +0000 Subject: [PATCH] For bug #167450, optimize leaf node selection by ordering nodes from highest to lowest overall reference count. svn path=/main/trunk/; revision=6010 --- pym/emerge/__init__.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pym/emerge/__init__.py b/pym/emerge/__init__.py index 6c1043937..2ce384d46 100644 --- a/pym/emerge/__init__.py +++ b/pym/emerge/__init__.py @@ -1971,6 +1971,16 @@ class depgraph: break return acceptable + def _merge_order_bias(self, nodes): + """Order nodes from highest to lowest overall reference count for + optimal leaf node selection.""" + node_info = {} + for node in self._parent_child_digraph.order: + node_info[node] = len(self.digraph.parent_nodes(node)) + def cmp_merge_preference(node1, node2): + return node_info[node2] - node_info[node1] + nodes.sort(cmp_merge_preference) + def altlist(self, reversed=False): if reversed in self._altlist_cache: return self._altlist_cache[reversed][:] @@ -1980,6 +1990,7 @@ class depgraph: self._altlist_cache[reversed] = retlist[:] return retlist mygraph=self.digraph.copy() + self._merge_order_bias(mygraph.order) myblockers = self.blocker_digraph.copy() retlist=[] circular_blocks = False -- 2.26.2