summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2021-02-13 00:57:41 -0800
committerGreg Becker <becker33@llnl.gov>2021-03-31 14:39:23 -0700
commitfd12cba18b79f1808f317f22672e2b7a8b385536 (patch)
tree27479a7921ec7a14800600619a02d0bb74e41176 /lib
parentbb60dbd2ad1e059a6cdbccc83273ed36a9ed51c8 (diff)
downloadspack-fd12cba18b79f1808f317f22672e2b7a8b385536.tar.gz
spack-fd12cba18b79f1808f317f22672e2b7a8b385536.tar.bz2
spack-fd12cba18b79f1808f317f22672e2b7a8b385536.tar.xz
spack-fd12cba18b79f1808f317f22672e2b7a8b385536.zip
specs: speed up traversal by avoiding redundant canonicalization
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/spec.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/spack/spack/spec.py b/lib/spack/spack/spec.py
index 19fb91427b..e43947b60b 100644
--- a/lib/spack/spack/spec.py
+++ b/lib/spack/spack/spec.py
@@ -1382,7 +1382,16 @@ class Spec(object):
cover = kwargs.get('cover', 'nodes')
direction = kwargs.get('direction', 'children')
order = kwargs.get('order', 'pre')
- deptype = dp.canonical_deptype(deptype)
+
+ # we don't want to run canonical_deptype every time through
+ # traverse, because it is somewhat expensive. This ensures we
+ # canonicalize only once.
+ canonical_deptype = kwargs.get("canonical_deptype", None)
+ if canonical_deptype is None:
+ deptype = dp.canonical_deptype(deptype)
+ kwargs["canonical_deptype"] = deptype
+ else:
+ deptype = canonical_deptype
# Make sure kwargs have legal values; raise ValueError if not.
def validate(name, val, allowed_values):