diff options
author | Steven Knight <knight@baldmt.com> | 2002-02-05 20:28:24 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2002-02-05 20:28:24 (GMT) |
commit | 5cadc347bec33395f08d9d7a999628a53e9ff69f (patch) | |
tree | c97b0dc76fa573f7939aa4b2e729e0f2c00b6a32 /src/engine/SCons/Scanner/C.py | |
parent | f6c20c8f66928d7d9845717cca12770dbfc86a59 (diff) | |
download | SCons-5cadc347bec33395f08d9d7a999628a53e9ff69f.zip SCons-5cadc347bec33395f08d9d7a999628a53e9ff69f.tar.gz SCons-5cadc347bec33395f08d9d7a999628a53e9ff69f.tar.bz2 |
More performance optimizations (Charles Crain)
Diffstat (limited to 'src/engine/SCons/Scanner/C.py')
-rw-r--r-- | src/engine/SCons/Scanner/C.py | 47 |
1 files changed, 27 insertions, 20 deletions
diff --git a/src/engine/SCons/Scanner/C.py b/src/engine/SCons/Scanner/C.py index f3c9907..51235c3 100644 --- a/src/engine/SCons/Scanner/C.py +++ b/src/engine/SCons/Scanner/C.py @@ -38,6 +38,8 @@ import SCons.Util include_re = re.compile('^[ \t]*#[ \t]*include[ \t]+(<|")([\\w./\\\\]+)(>|")', re.M) +include_cache = {} + def CScan(fs = SCons.Node.FS.default_fs): "Return a prototype Scanner instance for scanning C/C++ source files" cs = CScanner(scan, "CScan", [fs, ()], @@ -96,27 +98,31 @@ def scan(node, env, args = [SCons.Node.FS.default_fs, ()]): fs, cpppath = args nodes = [] - if node.exists(): - - # cache the includes list in node so we only scan it once: - if hasattr(node, 'includes'): - includes = node.includes - else: - includes = include_re.findall(node.get_contents()) - node.includes = includes - - source_dir = node.get_dir() + try: + nodes = node.found_includes[cpppath] + except KeyError: + if node.exists(): - for include in includes: - if include[0] == '"': - node = SCons.Util.find_file(include[1], (source_dir,) + cpppath, - fs.File) + # cache the includes list in node so we only scan it once: + if hasattr(node, 'includes'): + includes = node.includes else: - node = SCons.Util.find_file(include[1], cpppath + (source_dir,), - fs.File) - - if not node is None: - nodes.append(node) + includes = include_re.findall(node.get_contents()) + node.includes = includes + + source_dir = node.get_dir() + + for include in includes: + if include[0] == '"': + n = SCons.Util.find_file(include[1], (source_dir,) + cpppath, + fs.File) + else: + n = SCons.Util.find_file(include[1], cpppath + (source_dir,), + fs.File) + + if not n is None: + nodes.append(n) + node.found_includes[cpppath] = nodes # Schwartzian transform from the Python FAQ Wizard def st(List, Metric): @@ -129,7 +135,8 @@ def scan(node, env, args = [SCons.Node.FS.default_fs, ()]): return map(stripit, paired) def normalize(node): - return os.path.normpath(str(node)) + return str(node) return st(nodes, normalize) + |