Skip to content

Commit

Permalink
only allocate the start term if it's needed
Browse files Browse the repository at this point in the history
  • Loading branch information
Eh2406 committed Sep 6, 2024
1 parent 341ec89 commit c3773bd
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/internal/partial_solution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -485,15 +485,15 @@ impl<DP: DependencyProvider> PartialSolution<DP> {
.get(satisfier_package)
.expect("satisfier package not in incompat");

let start_term = accum_term.intersection(&incompat_term.negate());
let out = satisfier_pa.satisfier(satisfier_package, &start_term);

satisfied_map.insert(
satisfier_package,
if accum_term.subset_of(incompat_term) {
(None, 0, DecisionLevel(1))
} else {
out
satisfier_pa.satisfier(
satisfier_package,
&accum_term.intersection(&incompat_term.negate()),
)
},
);

Expand All @@ -516,14 +516,16 @@ impl<P: Package, VS: VersionSet, M: Eq + Clone + Debug + Display> PackageAssignm
package: &P,
start_term: &Term<VS>,
) -> (Option<IncompId<P, VS, M>>, u32, DecisionLevel) {
let empty = Term::empty();
// Indicate if we found a satisfier in the list of derivations, otherwise it will be the decision.
let idx = self
.dated_derivations
.as_slice()
.partition_point(|dd| !dd.accumulated_intersection.is_disjoint(start_term));
if let Some(dd) = self.dated_derivations.get(idx) {
debug_assert_eq!(dd.accumulated_intersection.intersection(start_term), empty);
debug_assert_eq!(
dd.accumulated_intersection.intersection(start_term),
Term::empty()
);
return (Some(dd.cause), dd.global_index, dd.decision_level);
}
// If it wasn't found in the derivations,
Expand Down

0 comments on commit c3773bd

Please sign in to comment.