From: Eh2406 Date: Thu, 5 Apr 2018 20:34:49 +0000 (-0400) Subject: use more Rc in the part of resolver that gets cloned a lot X-Git-Tag: archive/raspbian/0.35.0-2+rpi1~3^2^2^2^2^2^2^2~22^2~1^2~93^2~1 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=736c3d7bb79fb0b29c479e3191e5cad27f9872fb;p=cargo.git use more Rc in the part of resolver that gets cloned a lot --- diff --git a/src/cargo/core/resolver/context.rs b/src/cargo/core/resolver/context.rs index b2b49a6b5..f132463e3 100644 --- a/src/cargo/core/resolver/context.rs +++ b/src/cargo/core/resolver/context.rs @@ -23,7 +23,7 @@ pub struct Context { // switch to persistent hash maps if we can at some point or otherwise // make these much cheaper to clone in general. pub activations: Activations, - pub resolve_features: HashMap>, + pub resolve_features: HashMap>>, pub links: HashMap, // These are two cheaply-cloneable lists (O(1) clone) which are effectively @@ -36,6 +36,8 @@ pub struct Context { pub warnings: RcList, } +pub type Activations = HashMap<(InternedString, SourceId), Rc>>; + impl Context { pub fn new() -> Context { Context { @@ -246,10 +248,13 @@ impl Context { let set = self.resolve_features .entry(pkgid.clone()) - .or_insert_with(HashSet::new); + .or_insert_with(|| Rc::new(HashSet::new())); + + let mut inner: HashSet<_> = (**set).clone(); for feature in reqs.used { - set.insert(InternedString::new(feature)); + inner.insert(InternedString::new(feature)); } + *set = Rc::new(inner); } Ok(ret) @@ -405,5 +410,3 @@ impl<'r> Requirements<'r> { } } } - -pub type Activations = HashMap<(InternedString, SourceId), Rc>>;