mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-28 11:20:36 +00:00
we dont need both maps
This commit is contained in:
parent
053d8279ae
commit
8418a3ae58
@ -91,16 +91,13 @@ pub struct PackageRegistry<'cfg> {
|
|||||||
type LockedMap = HashMap<
|
type LockedMap = HashMap<
|
||||||
// The first level of key-ing done in this hash map is the source that
|
// The first level of key-ing done in this hash map is the source that
|
||||||
// dependencies come from, identified by a `SourceId`.
|
// dependencies come from, identified by a `SourceId`.
|
||||||
SourceId,
|
// The next level is keyed by the name of the package...
|
||||||
HashMap<
|
(SourceId, InternedString),
|
||||||
// This next level is keyed by the name of the package...
|
|
||||||
InternedString,
|
|
||||||
// ... and the value here is a list of tuples. The first element of each
|
// ... and the value here is a list of tuples. The first element of each
|
||||||
// tuple is a package which has the source/name used to get to this
|
// tuple is a package which has the source/name used to get to this
|
||||||
// point. The second element of each tuple is the list of locked
|
// point. The second element of each tuple is the list of locked
|
||||||
// dependencies that the first element has.
|
// dependencies that the first element has.
|
||||||
Vec<(PackageId, Vec<PackageId>)>,
|
Vec<(PackageId, Vec<PackageId>)>,
|
||||||
>,
|
|
||||||
>;
|
>;
|
||||||
|
|
||||||
#[derive(PartialEq, Eq, Clone, Copy)]
|
#[derive(PartialEq, Eq, Clone, Copy)]
|
||||||
@ -203,11 +200,10 @@ impl<'cfg> PackageRegistry<'cfg> {
|
|||||||
for dep in deps.iter() {
|
for dep in deps.iter() {
|
||||||
trace!("\t-> {}", dep);
|
trace!("\t-> {}", dep);
|
||||||
}
|
}
|
||||||
let sub_map = self
|
let sub_vec = self
|
||||||
.locked
|
.locked
|
||||||
.entry(id.source_id())
|
.entry((id.source_id(), id.name()))
|
||||||
.or_insert_with(HashMap::new);
|
.or_insert_with(Vec::new);
|
||||||
let sub_vec = sub_map.entry(id.name()).or_insert_with(Vec::new);
|
|
||||||
sub_vec.push((id, deps));
|
sub_vec.push((id, deps));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -637,8 +633,7 @@ fn lock(
|
|||||||
summary: Summary,
|
summary: Summary,
|
||||||
) -> Summary {
|
) -> Summary {
|
||||||
let pair = locked
|
let pair = locked
|
||||||
.get(&summary.source_id())
|
.get(&(summary.source_id(), summary.name()))
|
||||||
.and_then(|map| map.get(&summary.name()))
|
|
||||||
.and_then(|vec| vec.iter().find(|&&(id, _)| id == summary.package_id()));
|
.and_then(|vec| vec.iter().find(|&&(id, _)| id == summary.package_id()));
|
||||||
|
|
||||||
trace!("locking summary of {}", summary.package_id());
|
trace!("locking summary of {}", summary.package_id());
|
||||||
@ -727,8 +722,7 @@ fn lock(
|
|||||||
// all known locked packages to see if they match this dependency.
|
// all known locked packages to see if they match this dependency.
|
||||||
// If anything does then we lock it to that and move on.
|
// If anything does then we lock it to that and move on.
|
||||||
let v = locked
|
let v = locked
|
||||||
.get(&dep.source_id())
|
.get(&(dep.source_id(), dep.package_name()))
|
||||||
.and_then(|map| map.get(&dep.package_name()))
|
|
||||||
.and_then(|vec| vec.iter().find(|&&(id, _)| dep.matches_id(id)));
|
.and_then(|vec| vec.iter().find(|&&(id, _)| dep.matches_id(id)));
|
||||||
if let Some(&(id, _)) = v {
|
if let Some(&(id, _)) = v {
|
||||||
trace!("\tsecond hit on {}", id);
|
trace!("\tsecond hit on {}", id);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user