From: stevenknight Date: Sun, 30 Jun 2002 13:44:36 +0000 (+0000) Subject: Optimzation in the C Scanner: don't re-sort the list each time. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=e5418d54f5ef7f9d21f2e1140601e0eb793a9716;p=scons.git Optimzation in the C Scanner: don't re-sort the list each time. git-svn-id: http://scons.tigris.org/svn/scons/trunk@399 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- diff --git a/src/engine/SCons/Scanner/C.py b/src/engine/SCons/Scanner/C.py index b54c8511..d37bda86 100644 --- a/src/engine/SCons/Scanner/C.py +++ b/src/engine/SCons/Scanner/C.py @@ -87,11 +87,7 @@ def scan(node, env, target, fs = SCons.Node.FS.default_fs): cpppath = target.cpppath - nodes = [] - - try: - nodes = node.found_includes[cpppath] - except KeyError: + if not node.found_includes.has_key(cpppath): if node.exists(): # cache the includes list in node so we only scan it once: @@ -101,8 +97,8 @@ def scan(node, env, target, fs = SCons.Node.FS.default_fs): includes = include_re.findall(node.get_contents()) node.includes = includes + nodes = [] source_dir = node.get_dir() - for include in includes: if include[0] == '"': n = SCons.Node.FS.find_file(include[1], @@ -118,21 +114,24 @@ def scan(node, env, target, fs = SCons.Node.FS.default_fs): else: SCons.Warnings.warn(SCons.Warnings.DependencyWarning, "No dependency generated for file: %s (included from: %s) -- file not found" % (include[1], node)) - node.found_includes[cpppath] = nodes - # Schwartzian transform from the Python FAQ Wizard - def st(List, Metric): - def pairing(element, M = Metric): - return (M(element), element) - def stripit(pair): - return pair[1] - paired = map(pairing, List) - paired.sort() - return map(stripit, paired) + # Schwartzian transform from the Python FAQ Wizard + def st(List, Metric): + def pairing(element, M = Metric): + return (M(element), element) + def stripit(pair): + return pair[1] + paired = map(pairing, List) + paired.sort() + return map(stripit, paired) + + def normalize(node): + return str(node) - def normalize(node): - return str(node) + node.found_includes[cpppath] = st(nodes, normalize) - return st(nodes, normalize) + else: + node.found_includes[cpppath] = [] + return node.found_includes[cpppath]