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
This commit is contained in:
parent
afc99ca516
commit
1ba4c1af63
1 changed files with 9 additions and 5 deletions
|
@ -2338,7 +2338,6 @@ def _constrain_dependencies(self, other):
|
||||||
|
|
||||||
def common_dependencies(self, other):
|
def common_dependencies(self, other):
|
||||||
"""Return names of dependencies that self an other have in common."""
|
"""Return names of dependencies that self an other have in common."""
|
||||||
# XXX(deptype): handle deptypes via deptype kwarg.
|
|
||||||
common = set(
|
common = set(
|
||||||
s.name for s in self.traverse(root=False))
|
s.name for s in self.traverse(root=False))
|
||||||
common.intersection_update(
|
common.intersection_update(
|
||||||
|
@ -2469,8 +2468,13 @@ def satisfies_dependencies(self, other, strict=False):
|
||||||
"""
|
"""
|
||||||
other = self._autospec(other)
|
other = self._autospec(other)
|
||||||
|
|
||||||
|
# If there are no constraints to satisfy, we're done.
|
||||||
|
if not other._dependencies:
|
||||||
|
return True
|
||||||
|
|
||||||
if strict:
|
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
|
return False
|
||||||
|
|
||||||
selfdeps = self.traverse(root=False)
|
selfdeps = self.traverse(root=False)
|
||||||
|
@ -2479,9 +2483,9 @@ def satisfies_dependencies(self, other, strict=False):
|
||||||
for dep in otherdeps):
|
for dep in otherdeps):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
elif not self._dependencies or not other._dependencies:
|
elif not self._dependencies:
|
||||||
# if either spec doesn't restrict dependencies then both are
|
# if not strict, this spec *could* eventually satisfy the
|
||||||
# compatible.
|
# constraints on other.
|
||||||
return True
|
return True
|
||||||
|
|
||||||
# Handle first-order constraints directly
|
# Handle first-order constraints directly
|
||||||
|
|
Loading…
Reference in a new issue