diff options
author | Alexey Klimkin <klimkin@gmail.com> | 2016-05-26 18:03:00 (GMT) |
---|---|---|
committer | Alexey Klimkin <klimkin@gmail.com> | 2016-05-26 18:03:00 (GMT) |
commit | 931e855a7b3b76622e4232fa94ea344e78e8db0a (patch) | |
tree | 058b970466affa3b448328d34bed5a0915449fc9 | |
parent | 7dc268533b72dca23fcf1cf6ffc6bc4ae1f937fd (diff) | |
download | SCons-931e855a7b3b76622e4232fa94ea344e78e8db0a.zip SCons-931e855a7b3b76622e4232fa94ea344e78e8db0a.tar.gz SCons-931e855a7b3b76622e4232fa94ea344e78e8db0a.tar.bz2 |
Optimize implicit dependency scan
When calculating path, performance spent on two things:
- Variable expansion, if CPPPATH contains any variables
- CPPPATH flattening
Use memoization to optimize PATH evaluation across all dependencies per node.
-rw-r--r-- | src/engine/SCons/Node/__init__.py | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/src/engine/SCons/Node/__init__.py b/src/engine/SCons/Node/__init__.py index 86a5c1d..d3fc9eb 100644 --- a/src/engine/SCons/Node/__init__.py +++ b/src/engine/SCons/Node/__init__.py @@ -924,9 +924,9 @@ class Node(object): scanner's recursive flag says that we should. """ nodes = [self] - seen = {} - seen[self] = 1 + seen = set(nodes) dependencies = [] + path_memo = {} root_node_scanner = self._get_scanner(env, initial_scanner, None, kw) @@ -934,31 +934,33 @@ class Node(object): node = nodes.pop(0) scanner = node._get_scanner(env, initial_scanner, root_node_scanner, kw) - if not scanner: continue - path = path_func(scanner) + try: + path = path_memo[scanner] + except KeyError: + path = path_func(scanner) + path_memo[scanner] = path included_deps = [x for x in node.get_found_includes(env, scanner, path) if x not in seen] if included_deps: dependencies.extend(included_deps) - for dep in included_deps: - seen[dep] = 1 + seen.update(included_deps) nodes.extend(scanner.recurse_nodes(included_deps)) return dependencies def _get_scanner(self, env, initial_scanner, root_node_scanner, kw): - if not initial_scanner: + if initial_scanner: + # handle explicit scanner case + scanner = initial_scanner.select(self) + else: # handle implicit scanner case scanner = self.get_env_scanner(env, kw) if scanner: scanner = scanner.select(self) - else: - # handle explicit scanner case - scanner = initial_scanner.select(self) - + if not scanner: # no scanner could be found for the given node's scanner key; # thus, make an attempt at using a default. |