@@ -13,9 +13,7 @@ use crate::util::CargoResult;
13
13
use crate :: util:: Graph ;
14
14
15
15
use super :: errors:: ActivateResult ;
16
- use super :: types:: {
17
- ConflictMap , ConflictReason , DepInfo , GraphNode , Method , RcList , RegistryQueryer ,
18
- } ;
16
+ use super :: types:: { ConflictMap , ConflictReason , DepInfo , GraphNode , Method , RegistryQueryer } ;
19
17
20
18
pub use super :: encode:: { EncodableDependency , EncodablePackageId , EncodableResolve } ;
21
19
pub use super :: encode:: { Metadata , WorkspaceResolve } ;
@@ -37,16 +35,9 @@ pub struct Context {
37
35
pub public_dependency :
38
36
Option < im_rc:: HashMap < PackageId , im_rc:: HashMap < InternedString , ( PackageId , bool ) > > > ,
39
37
40
- // This is somewhat redundant with the `resolve_graph` that stores the same data,
41
- // but for querying in the opposite order.
42
38
/// a way to look up for a package in activations what packages required it
43
39
/// and all of the exact deps that it fulfilled.
44
40
pub parents : Graph < PackageId , Rc < Vec < Dependency > > > ,
45
-
46
- // These are two cheaply-cloneable lists (O(1) clone) which are effectively
47
- // hash maps but are built up as "construction lists". We'll iterate these
48
- // at the very end and actually construct the map that we're making.
49
- pub resolve_graph : RcList < GraphNode > ,
50
41
}
51
42
52
43
/// When backtracking it can be useful to know how far back to go.
@@ -94,7 +85,6 @@ impl PackageId {
94
85
impl Context {
95
86
pub fn new ( check_public_visible_dependencies : bool ) -> Context {
96
87
Context {
97
- resolve_graph : RcList :: new ( ) ,
98
88
resolve_features : im_rc:: HashMap :: new ( ) ,
99
89
links : im_rc:: HashMap :: new ( ) ,
100
90
public_dependency : if check_public_visible_dependencies {
@@ -122,7 +112,6 @@ impl Context {
122
112
) ;
123
113
}
124
114
im_rc:: hashmap:: Entry :: Vacant ( v) => {
125
- self . resolve_graph . push ( GraphNode :: Add ( id) ) ;
126
115
if let Some ( link) = summary. links ( ) {
127
116
ensure ! (
128
117
self . links. insert( link, id) . is_none( ) ,
@@ -340,16 +329,15 @@ impl Context {
340
329
}
341
330
342
331
pub fn graph ( & self ) -> Graph < PackageId , Vec < Dependency > > {
343
- let mut graph: Graph < PackageId , Vec < Dependency > > = Graph :: new ( ) ;
344
- let mut cur = & self . resolve_graph ;
345
- while let Some ( ref node ) = cur . head {
346
- match node . 0 {
347
- GraphNode :: Add ( ref p ) => graph . add ( p . clone ( ) ) ,
348
- GraphNode :: Link ( ref a , ref b , ref dep ) => {
349
- graph . link ( a . clone ( ) , b . clone ( ) ) . push ( dep . clone ( ) ) ;
350
- }
332
+ let mut graph = Graph :: new ( ) ;
333
+ self . activations
334
+ . values ( )
335
+ . for_each ( | ( r , _ ) | graph . add ( r . package_id ( ) ) ) ;
336
+ for i in self . parents . iter ( ) {
337
+ graph . add ( * i ) ;
338
+ for ( o , e ) in self . parents . edges ( i ) {
339
+ * graph . link ( * o , * i ) = e . to_vec ( ) ;
351
340
}
352
- cur = & node. 1 ;
353
341
}
354
342
graph
355
343
}
0 commit comments