From: stevenknight Date: Thu, 21 Mar 2002 07:16:35 +0000 (+0000) Subject: Speed up SCons.Sig.Calculator.bsig() (second most time-consuming function) by 6%... X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=ef8e3d9b6d58c6746c26631b6a513b9604a8327b;p=scons.git Speed up SCons.Sig.Calculator.bsig() (second most time-consuming function) by 6%-12% by using the new Walker eval_func argument. git-svn-id: http://scons.tigris.org/svn/scons/trunk@299 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- diff --git a/src/engine/SCons/Sig/__init__.py b/src/engine/SCons/Sig/__init__.py index 7e93123e..3770adf1 100644 --- a/src/engine/SCons/Sig/__init__.py +++ b/src/engine/SCons/Sig/__init__.py @@ -204,18 +204,19 @@ class Calculator: # derived files, because calling get_signature() on the # derived nodes will in turn call bsig() again and do that # for us. Hence: - def walk_non_derived(n, parent, myself=node): + sigs = [] + def non_derived(n, parent, myself=node): if not n.builder or n is myself: return filter(lambda x, i=myself.ignore: x not in i, n.all_children(None)) return [] - walker = SCons.Node.Walker(node, walk_non_derived) - sigs = [] - while 1: + def get_sig(n, parent, self=self, myself=node, sigs=sigs): + if not n is myself: + sigs.append(self.get_signature(n)) + walker = SCons.Node.Walker(node, non_derived, eval_func=get_sig) + child = walker.next() + while child: child = walker.next() - if child is None: break - if child is node: continue # skip the node itself - sigs.append(self.get_signature(child)) if node.builder: sigs.append(self.module.signature(node.builder_sig_adapter())) diff --git a/src/engine/SCons/Taskmaster.py b/src/engine/SCons/Taskmaster.py index 404355ec..c97d28c4 100644 --- a/src/engine/SCons/Taskmaster.py +++ b/src/engine/SCons/Taskmaster.py @@ -117,11 +117,11 @@ class Task: nodes = {} for t in self.targets: def get_parents(node, parent): return node.get_parents() - walker = SCons.Node.Walker(t, get_parents) - while 1: + def set_nodes(node, parent, nodes=nodes): nodes[node] = 1 + walker = SCons.Node.Walker(t, get_parents, eval_func=set_nodes) + n = walker.next() + while n: n = walker.next() - if n == None: break - nodes[n] = 1 pending = filter(lambda x: x.get_state() == SCons.Node.pending, nodes.keys()) tasks = {}