@@ -73,9 +73,9 @@ pub struct PartialSolution<DP: DependencyProvider> {
7373 #[ allow( clippy:: type_complexity) ]
7474 prioritized_potential_packages :
7575 PriorityQueue < Id < DP :: P > , ( DP :: Priority , Reverse < u32 > ) , BuildHasherDefault < FxHasher > > ,
76- /// Contains all packages that **have** had there assignments changed since
77- /// the last time `prioritize` has been called on them .
78- unprioritized_potential_packages : FnvIndexSet < Id < DP :: P > > ,
76+ /// Packages whose derivations changed since the last time `prioritize` was called and need
77+ /// their priorities to be updated .
78+ outdated_priorities : FnvIndexSet < Id < DP :: P > > ,
7979 /// Whether we have never backtracked, to enable fast path optimizations.
8080 has_ever_backtracked : bool ,
8181}
@@ -183,7 +183,7 @@ impl<DP: DependencyProvider> PartialSolution<DP> {
183183 current_decision_level : DecisionLevel ( 0 ) ,
184184 package_assignments : FnvIndexMap :: default ( ) ,
185185 prioritized_potential_packages : PriorityQueue :: default ( ) ,
186- unprioritized_potential_packages : FnvIndexSet :: default ( ) ,
186+ outdated_priorities : FnvIndexSet :: default ( ) ,
187187 has_ever_backtracked : false ,
188188 }
189189 }
@@ -299,7 +299,7 @@ impl<DP: DependencyProvider> PartialSolution<DP> {
299299 * t = t. intersection ( & dated_derivation. accumulated_intersection ) ;
300300 dated_derivation. accumulated_intersection = t. clone ( ) ;
301301 if t. is_positive ( ) {
302- self . unprioritized_potential_packages . insert ( package) ;
302+ self . outdated_priorities . insert ( package) ;
303303 }
304304 }
305305 }
@@ -308,7 +308,7 @@ impl<DP: DependencyProvider> PartialSolution<DP> {
308308 Entry :: Vacant ( v) => {
309309 let term = dated_derivation. accumulated_intersection . clone ( ) ;
310310 if term. is_positive ( ) {
311- self . unprioritized_potential_packages . insert ( package) ;
311+ self . outdated_priorities . insert ( package) ;
312312 }
313313 v. insert ( PackageAssignments {
314314 smallest_decision_level : self . current_decision_level ,
@@ -327,6 +327,12 @@ impl<DP: DependencyProvider> PartialSolution<DP> {
327327 . get_range ( current_decision_level. 0 as usize ..)
328328 . unwrap ( )
329329 . iter ( )
330+ . filter ( move |( _, pa) | {
331+ // We only actually need to update the package if it was changed
332+ // since the last time we called prioritize, which means it's highest decision level
333+ // is the current decision level, or if we backtracked in the meantime.
334+ pa. highest_decision_level == current_decision_level
335+ } )
330336 . filter_map ( |( & p, pa) | {
331337 Some ( ( p, pa. assignments_intersection . potential_package_filter ( ) ?) )
332338 } )
@@ -338,7 +344,7 @@ impl<DP: DependencyProvider> PartialSolution<DP> {
338344 mut prioritizer : impl FnMut ( Id < DP :: P > , & DP :: VS ) -> DP :: Priority ,
339345 ) -> Option < Id < DP :: P > > {
340346 let prioritized_potential_packages = & mut self . prioritized_potential_packages ;
341- while let Some ( p) = self . unprioritized_potential_packages . pop ( ) {
347+ while let Some ( p) = self . outdated_priorities . pop ( ) {
342348 let Some ( pa) = self . package_assignments . get ( & p) else {
343349 continue ;
344350 } ;
@@ -361,25 +367,6 @@ impl<DP: DependencyProvider> PartialSolution<DP> {
361367 None
362368 }
363369
364- /// Manually update a package priority that changed independent of the range.
365- pub fn update_priority ( & mut self , package : Id < DP :: P > , priority : DP :: Priority ) {
366- if self
367- . package_assignments
368- . get ( & package)
369- . and_then ( |assignment| {
370- assignment
371- . assignments_intersection
372- . potential_package_filter ( )
373- } )
374- . is_none ( )
375- {
376- // Only prioritize packages up for decision
377- return ;
378- }
379- self . prioritized_potential_packages
380- . push ( package, ( priority, Reverse ( package. into_raw ( ) as u32 ) ) ) ;
381- }
382-
383370 /// If a partial solution has, for every positive derivation,
384371 /// a corresponding decision that satisfies that assignment,
385372 /// it's a total solution and version solving has succeeded.
@@ -429,7 +416,7 @@ impl<DP: DependencyProvider> PartialSolution<DP> {
429416 . is_some ( )
430417 && self . prioritized_potential_packages . get ( p) . is_none ( )
431418 {
432- self . unprioritized_potential_packages . insert ( * p) ;
419+ self . outdated_priorities . insert ( * p) ;
433420 }
434421 true
435422 } else {
@@ -458,7 +445,7 @@ impl<DP: DependencyProvider> PartialSolution<DP> {
458445
459446 self . prioritized_potential_packages . remove ( p) ;
460447 if pa. assignments_intersection . term ( ) . is_positive ( ) {
461- self . unprioritized_potential_packages . insert ( * p) ;
448+ self . outdated_priorities . insert ( * p) ;
462449 }
463450 true
464451 }
0 commit comments