summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2017-10-13 17:53:29 -0700
committerTodd Gamblin <tgamblin@llnl.gov>2017-10-13 19:46:57 -0700
commit1ba4c1af6367697da62bad0262dacbd47eb4e896 (patch)
treee6808f4eda816104800bb9d6d6a4d610961646f0 /lib
parentafc99ca51699234ee3353013dba8f92cb1d28e2f (diff)
downloadspack-1ba4c1af6367697da62bad0262dacbd47eb4e896.tar.gz
spack-1ba4c1af6367697da62bad0262dacbd47eb4e896.tar.bz2
spack-1ba4c1af6367697da62bad0262dacbd47eb4e896.tar.xz
spack-1ba4c1af6367697da62bad0262dacbd47eb4e896.zip
Clean up logic in Sepc.satisfies_dependencies()
- This puts in a fast path when there are no dependencies to satisfy. - Reduces time spent to concretize r-rminer by 2x, down to 5s from 10s
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/spec.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/spack/spack/spec.py b/lib/spack/spack/spec.py
index 70a27fb951..dfc45850f7 100644
--- a/lib/spack/spack/spec.py
+++ b/lib/spack/spack/spec.py
@@ -2338,7 +2338,6 @@ class Spec(object):
def common_dependencies(self, other):
"""Return names of dependencies that self an other have in common."""
- # XXX(deptype): handle deptypes via deptype kwarg.
common = set(
s.name for s in self.traverse(root=False))
common.intersection_update(
@@ -2469,8 +2468,13 @@ class Spec(object):
"""
other = self._autospec(other)
+ # If there are no constraints to satisfy, we're done.
+ if not other._dependencies:
+ return True
+
if strict:
- if other._dependencies and not self._dependencies:
+ # if we have no dependencies, we can't satisfy any constraints.
+ if not self._dependencies:
return False
selfdeps = self.traverse(root=False)
@@ -2479,9 +2483,9 @@ class Spec(object):
for dep in otherdeps):
return False
- elif not self._dependencies or not other._dependencies:
- # if either spec doesn't restrict dependencies then both are
- # compatible.
+ elif not self._dependencies:
+ # if not strict, this spec *could* eventually satisfy the
+ # constraints on other.
return True
# Handle first-order constraints directly