Skip to content

Commit

Permalink
Add PartialSolution::prioritized_packages
Browse files Browse the repository at this point in the history
  • Loading branch information
konstin committed Jul 31, 2024
1 parent e2588bc commit 40f338c
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/internal/partial_solution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,24 @@ impl<DP: DependencyProvider> PartialSolution<DP> {
}
}

pub fn prioritized_packages(&self) -> impl Iterator<Item = (&DP::P, &DP::VS)> {
let check_all = self.changed_this_decision_level
== self.current_decision_level.0.saturating_sub(1) as usize;
let current_decision_level = self.current_decision_level;
self.package_assignments
.get_range(self.changed_this_decision_level..)
.unwrap()
.iter()
.filter(move |(_, pa)| {
// We only actually need to update the package if its Been changed
// since the last time we called prioritize.
// Which means it's highest decision level is the current decision level,
// or if we backtracked in the mean time.
check_all || pa.highest_decision_level == current_decision_level
})
.filter_map(|(p, pa)| pa.assignments_intersection.potential_package_filter(p))
}

pub fn pick_highest_priority_pkg(
&mut self,
prioritizer: impl Fn(&DP::P, &DP::VS) -> DP::Priority,
Expand Down

0 comments on commit 40f338c

Please sign in to comment.