Skip to content

Commit 25644b7

Browse files
committed
Remove an unnecessary HashMap when Vec works
Dependencies aren't necessarily unique per name as the same dependency can show up multiple times in various dependency kind lists, so it's not quite right to use a hash map anyway.
1 parent 6919fbf commit 25644b7

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/cargo/core/resolver/mod.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ fn activate(mut cx: Box<Context>,
182182

183183
// Next, transform all dependencies into a list of possible candidates which
184184
// can satisfy that dependency.
185-
let mut deps = try!(deps.into_iter().map(|(_dep_name, (dep, features))| {
185+
let mut deps = try!(deps.into_iter().map(|(dep, features)| {
186186
let mut candidates = try!(registry.query(dep));
187187
// When we attempt versions for a package, we'll want to start at the
188188
// maximum version and work our way down.
@@ -430,8 +430,7 @@ fn compatible(a: &semver::Version, b: &semver::Version) -> bool {
430430

431431
fn resolve_features<'a>(cx: &mut Context, parent: &'a Summary,
432432
method: Method)
433-
-> CargoResult<HashMap<&'a str,
434-
(&'a Dependency, Vec<String>)>> {
433+
-> CargoResult<Vec<(&'a Dependency, Vec<String>)>> {
435434
let dev_deps = match method {
436435
Method::Everything => true,
437436
Method::Required { dev_deps, .. } => dev_deps,
@@ -452,7 +451,7 @@ fn resolve_features<'a>(cx: &mut Context, parent: &'a Summary,
452451
});
453452

454453
let (mut feature_deps, used_features) = try!(build_features(parent, method));
455-
let mut ret = HashMap::new();
454+
let mut ret = Vec::new();
456455

457456
// Next, sanitize all requested features by whitelisting all the requested
458457
// features that correspond to optional dependencies
@@ -461,7 +460,7 @@ fn resolve_features<'a>(cx: &mut Context, parent: &'a Summary,
461460
if dep.is_optional() && !feature_deps.contains_key(dep.name()) {
462461
continue
463462
}
464-
let mut base = feature_deps.remove(dep.name()).unwrap_or(vec![]);
463+
let mut base = feature_deps.remove(dep.name()).unwrap_or(Vec::new());
465464
for feature in dep.features().iter() {
466465
base.push(feature.clone());
467466
if feature.contains("/") {
@@ -471,7 +470,7 @@ fn resolve_features<'a>(cx: &mut Context, parent: &'a Summary,
471470
feature)));
472471
}
473472
}
474-
ret.insert(dep.name(), (dep, base));
473+
ret.push((dep, base));
475474
}
476475

477476
// All features can only point to optional dependencies, in which case they

0 commit comments

Comments
 (0)