47
47
//! that we're implementing something that probably shouldn't be allocating all
48
48
//! over the place.
49
49
50
- use std:: collections:: { BTreeMap , BinaryHeap , HashMap , HashSet } ;
50
+ use std:: collections:: { BTreeMap , HashMap , HashSet } ;
51
51
use std:: mem;
52
52
use std:: rc:: Rc ;
53
53
use std:: time:: { Duration , Instant } ;
@@ -64,7 +64,7 @@ use util::profile;
64
64
65
65
use self :: context:: { Activations , Context } ;
66
66
use self :: types:: { ActivateError , ActivateResult , Candidate , ConflictReason , DepsFrame , GraphNode } ;
67
- use self :: types:: { RcVecIter , RegistryQueryer , ResolverProgress } ;
67
+ use self :: types:: { RcVecIter , RegistryQueryer , RemainingDeps , ResolverProgress } ;
68
68
69
69
pub use self :: encode:: { EncodableDependency , EncodablePackageId , EncodableResolve } ;
70
70
pub use self :: encode:: { Metadata , WorkspaceResolve } ;
@@ -170,15 +170,8 @@ fn activate_deps_loop(
170
170
summaries : & [ ( Summary , Method ) ] ,
171
171
config : Option < & Config > ,
172
172
) -> CargoResult < Context > {
173
- // Note that a `BinaryHeap` is used for the remaining dependencies that need
174
- // activation. This heap is sorted such that the "largest value" is the most
175
- // constrained dependency, or the one with the least candidates.
176
- //
177
- // This helps us get through super constrained portions of the dependency
178
- // graph quickly and hopefully lock down what later larger dependencies can
179
- // use (those with more candidates).
180
173
let mut backtrack_stack = Vec :: new ( ) ;
181
- let mut remaining_deps = BinaryHeap :: new ( ) ;
174
+ let mut remaining_deps = RemainingDeps :: new ( ) ;
182
175
183
176
// `past_conflicting_activations` is a cache of the reasons for each time we
184
177
// backtrack.
@@ -215,27 +208,15 @@ fn activate_deps_loop(
215
208
// its own dependencies in turn. The `backtrack_stack` is a side table of
216
209
// backtracking states where if we hit an error we can return to in order to
217
210
// attempt to continue resolving.
218
- while let Some ( mut deps_frame) = remaining_deps. pop ( ) {
211
+ while let Some ( ( just_here_for_the_error_messages, frame) ) =
212
+ remaining_deps. pop_most_constrained ( )
213
+ {
214
+ let ( mut parent, ( mut cur, ( mut dep, candidates, mut features) ) ) = frame;
215
+
219
216
// If we spend a lot of time here (we shouldn't in most cases) then give
220
217
// a bit of a visual indicator as to what we're doing.
221
218
printed. shell_status ( config) ?;
222
219
223
- let just_here_for_the_error_messages = deps_frame. just_for_error_messages ;
224
-
225
- // Figure out what our next dependency to activate is, and if nothing is
226
- // listed then we're entirely done with this frame (yay!) and we can
227
- // move on to the next frame.
228
- let frame = match deps_frame. remaining_siblings . next ( ) {
229
- Some ( sibling) => {
230
- let parent = Summary :: clone ( & deps_frame. parent ) ;
231
- remaining_deps. push ( deps_frame) ;
232
- ( parent, sibling)
233
- }
234
- None => continue ,
235
- } ;
236
- let ( mut parent, ( mut cur, ( mut dep, candidates, mut features) ) ) = frame;
237
- assert ! ( !remaining_deps. is_empty( ) ) ;
238
-
239
220
trace ! (
240
221
"{}[{}]>{} {} candidates" ,
241
222
parent. name( ) ,
@@ -365,7 +346,7 @@ fn activate_deps_loop(
365
346
Some ( BacktrackFrame {
366
347
cur,
367
348
context_backup : Context :: clone ( & cx) ,
368
- deps_backup : < BinaryHeap < DepsFrame > > :: clone ( & remaining_deps ) ,
349
+ deps_backup : remaining_deps . clone ( ) ,
369
350
remaining_candidates : remaining_candidates. clone ( ) ,
370
351
parent : Summary :: clone ( & parent) ,
371
352
dep : Dependency :: clone ( & dep) ,
@@ -453,7 +434,6 @@ fn activate_deps_loop(
453
434
{
454
435
if let Some ( ( other_parent, conflict) ) = remaining_deps
455
436
. iter ( )
456
- . flat_map ( |other| other. flatten ( ) )
457
437
// for deps related to us
458
438
. filter ( |& ( _, ref other_dep) | {
459
439
known_related_bad_deps. contains ( other_dep)
@@ -650,7 +630,7 @@ fn activate(
650
630
struct BacktrackFrame {
651
631
cur : usize ,
652
632
context_backup : Context ,
653
- deps_backup : BinaryHeap < DepsFrame > ,
633
+ deps_backup : RemainingDeps ,
654
634
remaining_candidates : RemainingCandidates ,
655
635
parent : Summary ,
656
636
dep : Dependency ,
0 commit comments