Skip to content

Commit 247837a

Browse files
committed
[Pubgrub] Kill PartialSolution.hasDecision(for:)
1 parent e2d886a commit 247837a

File tree

1 file changed

+7
-17
lines changed

1 file changed

+7
-17
lines changed

Sources/PackageGraph/Pubgrub.swift

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -569,11 +569,6 @@ final class PartialSolution<Identifier: PackageContainerIdentifier> {
569569
}
570570
}
571571

572-
/// Returns true if the given term satisfies the partial solution.
573-
func satisfies(_ term: Term<Identifier>) -> Bool {
574-
return self.relation(with: term) == .subset
575-
}
576-
577572
/// Find a pair of assignments, a satisfier and a previous satisfier, for
578573
/// which the partial solution satisfies a given incompatibility up to and
579574
/// including the satisfier. The previous satisfier represents the first
@@ -671,28 +666,23 @@ final class PartialSolution<Identifier: PackageContainerIdentifier> {
671666
return intersection
672667
}
673668

674-
/// Check if the solution contains a positive decision for a given package.
675-
private func hasDecision(for package: Identifier) -> Bool {
676-
for decision in assignments where decision.isDecision {
677-
if decision.term.package == package && decision.term.isPositive {
678-
return true
679-
}
680-
}
681-
return false
682-
}
683-
684669
/// Does the solution contain a decision for every derivation meaning
685670
/// that all necessary packages have been found?
686671
var isFinished: Bool {
687672
for derivation in assignments where !derivation.isDecision {
688-
// FIXME: We can just check in the decision dictionary.
689-
guard self.hasDecision(for: derivation.term.package) else {
673+
if !self.decisions.keys.contains(derivation.term.package) {
690674
return false
691675
}
692676
}
693677
return true
694678
}
695679

680+
/// Returns true if the given term satisfies the partial solution.
681+
func satisfies(_ term: Term<Identifier>) -> Bool {
682+
return self.relation(with: term) == .subset
683+
}
684+
685+
/// Returns the set relation of the partial solution with the given term.
696686
func relation(with term: Term<Identifier>) -> Term<Identifier>.SetRelation {
697687
let pkg = term.package
698688
if let positive = _positive[pkg] {

0 commit comments

Comments
 (0)