Skip to content

Commit 8418a3a

Browse files
committed
we dont need both maps
1 parent 053d827 commit 8418a3a

File tree

1 file changed

+12
-18
lines changed

1 file changed

+12
-18
lines changed

src/cargo/core/registry.rs

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -91,16 +91,13 @@ pub struct PackageRegistry<'cfg> {
9191
type LockedMap = HashMap<
9292
// The first level of key-ing done in this hash map is the source that
9393
// dependencies come from, identified by a `SourceId`.
94-
SourceId,
95-
HashMap<
96-
// This next level is keyed by the name of the package...
97-
InternedString,
98-
// ... and the value here is a list of tuples. The first element of each
99-
// tuple is a package which has the source/name used to get to this
100-
// point. The second element of each tuple is the list of locked
101-
// dependencies that the first element has.
102-
Vec<(PackageId, Vec<PackageId>)>,
103-
>,
94+
// The next level is keyed by the name of the package...
95+
(SourceId, InternedString),
96+
// ... and the value here is a list of tuples. The first element of each
97+
// tuple is a package which has the source/name used to get to this
98+
// point. The second element of each tuple is the list of locked
99+
// dependencies that the first element has.
100+
Vec<(PackageId, Vec<PackageId>)>,
104101
>;
105102

106103
#[derive(PartialEq, Eq, Clone, Copy)]
@@ -203,11 +200,10 @@ impl<'cfg> PackageRegistry<'cfg> {
203200
for dep in deps.iter() {
204201
trace!("\t-> {}", dep);
205202
}
206-
let sub_map = self
203+
let sub_vec = self
207204
.locked
208-
.entry(id.source_id())
209-
.or_insert_with(HashMap::new);
210-
let sub_vec = sub_map.entry(id.name()).or_insert_with(Vec::new);
205+
.entry((id.source_id(), id.name()))
206+
.or_insert_with(Vec::new);
211207
sub_vec.push((id, deps));
212208
}
213209

@@ -637,8 +633,7 @@ fn lock(
637633
summary: Summary,
638634
) -> Summary {
639635
let pair = locked
640-
.get(&summary.source_id())
641-
.and_then(|map| map.get(&summary.name()))
636+
.get(&(summary.source_id(), summary.name()))
642637
.and_then(|vec| vec.iter().find(|&&(id, _)| id == summary.package_id()));
643638

644639
trace!("locking summary of {}", summary.package_id());
@@ -727,8 +722,7 @@ fn lock(
727722
// all known locked packages to see if they match this dependency.
728723
// If anything does then we lock it to that and move on.
729724
let v = locked
730-
.get(&dep.source_id())
731-
.and_then(|map| map.get(&dep.package_name()))
725+
.get(&(dep.source_id(), dep.package_name()))
732726
.and_then(|vec| vec.iter().find(|&&(id, _)| dep.matches_id(id)));
733727
if let Some(&(id, _)) = v {
734728
trace!("\tsecond hit on {}", id);

0 commit comments

Comments
 (0)