~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/_known_graph_py.py

  • Committer: Vincent Ladeuil
  • Date: 2009-06-18 14:12:37 UTC
  • mto: This revision was merged to the branch mainline in revision 4466.
  • Revision ID: v.ladeuil+lp@free.fr-20090618141237-k9u7mrithzstg15z
Replace the existing KnownGraph._find_gdfo.

* bzrlib/_known_graph_pyx.pyx:
(_find_gdfo): pyrex version, almost as fast as the previous one,
but we don't need the linear dominator so we can potentially save
some time during __init__.

* bzrlib/_known_graph_py.py:
(KnownGraph._find_gdfo): Get rid of the inner function to stay in
sync with the pyrex version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
151
151
        pending = []
152
152
        known_parent_gdfos = dict.fromkeys(nodes.keys(), 0)
153
153
 
154
 
        def update_childs(node):
 
154
        for node in nodes.values():
 
155
            if not node.parent_keys:
 
156
                node.gdfo = 1
 
157
                known_parent_gdfos[node.key] = 0
 
158
                pending.append(node)
 
159
        while pending:
 
160
            node = pending.pop()
155
161
            for child_key in node.child_keys:
156
162
                child = nodes[child_key]
157
163
                known_parent_gdfos[child_key] += 1
162
168
                    # continue from there
163
169
                    pending.append(child)
164
170
 
165
 
        for node in self._nodes.itervalues():
166
 
            if not node.parent_keys:
167
 
                node.gdfo = 1
168
 
                known_parent_gdfos[node.key] = 0
169
 
                update_childs(node)
170
 
        while pending:
171
 
            update_childs(pending.pop())
172
 
 
173
171
    def x_find_gdfo(self):
174
172
        def find_tails():
175
173
            return [node for node in self._nodes.itervalues()