Skip to content

Commit c45c2a5

Browse files
committed
Replace hashmap with hashset
Signed-off-by: hi-rustin <[email protected]> Better code Signed-off-by: hi-rustin <[email protected]>
1 parent 58906aa commit c45c2a5

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

src/cargo/ops/tree/graph.rs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -234,27 +234,26 @@ impl<'a> Graph<'a> {
234234
let mut dupes: Vec<(&Node, usize)> = packages
235235
.into_iter()
236236
.filter(|(_name, indexes)| {
237-
let mut pkg_map = HashMap::new();
238237
indexes
239238
.into_iter()
240-
.filter(|(node, _)| {
241-
// Do not treat duplicates on the host or target as duplicates.
242-
let ignore_kind_package = match node {
239+
.map(|(node, _)| {
240+
match node {
243241
Node::Package {
244242
package_id,
245243
features,
246244
..
247-
} => Node::Package {
248-
package_id: package_id.clone(),
249-
features: features.clone(),
250-
kind: CompileKind::Host,
251-
},
245+
} => {
246+
// Do not treat duplicates on the host or target as duplicates.
247+
Node::Package {
248+
package_id: package_id.clone(),
249+
features: features.clone(),
250+
kind: CompileKind::Host,
251+
}
252+
}
252253
_ => unreachable!(),
253-
};
254-
!pkg_map.contains_key(&ignore_kind_package)
255-
&& pkg_map.insert(ignore_kind_package, ()).is_none()
254+
}
256255
})
257-
.collect::<Vec<&(&Node, usize)>>()
256+
.collect::<HashSet<_>>()
258257
.len()
259258
> 1
260259
})

0 commit comments

Comments
 (0)