@@ -23,7 +23,7 @@ pub struct Context {
23
23
// switch to persistent hash maps if we can at some point or otherwise
24
24
// make these much cheaper to clone in general.
25
25
pub activations : Activations ,
26
- pub resolve_features : HashMap < PackageId , HashSet < InternedString > > ,
26
+ pub resolve_features : HashMap < PackageId , Rc < HashSet < InternedString > > > ,
27
27
pub links : HashMap < InternedString , PackageId > ,
28
28
29
29
// These are two cheaply-cloneable lists (O(1) clone) which are effectively
@@ -36,6 +36,8 @@ pub struct Context {
36
36
pub warnings : RcList < String > ,
37
37
}
38
38
39
+ pub type Activations = HashMap < ( InternedString , SourceId ) , Rc < Vec < Summary > > > ;
40
+
39
41
impl Context {
40
42
pub fn new ( ) -> Context {
41
43
Context {
@@ -246,10 +248,13 @@ impl Context {
246
248
247
249
let set = self . resolve_features
248
250
. entry ( pkgid. clone ( ) )
249
- . or_insert_with ( HashSet :: new) ;
251
+ . or_insert_with ( || Rc :: new ( HashSet :: new ( ) ) ) ;
252
+
253
+ let mut inner: HashSet < _ > = ( * * set) . clone ( ) ;
250
254
for feature in reqs. used {
251
- set . insert ( InternedString :: new ( feature) ) ;
255
+ inner . insert ( InternedString :: new ( feature) ) ;
252
256
}
257
+ * set = Rc :: new ( inner) ;
253
258
}
254
259
255
260
Ok ( ret)
@@ -405,5 +410,3 @@ impl<'r> Requirements<'r> {
405
410
}
406
411
}
407
412
}
408
-
409
- pub type Activations = HashMap < ( InternedString , SourceId ) , Rc < Vec < Summary > > > ;
0 commit comments