Skip to content

Commit 053d827

Browse files
committed
don't need to clone this string
1 parent 46b50bb commit 053d827

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/cargo/core/registry.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ use log::{debug, trace};
55
use semver::VersionReq;
66
use url::Url;
77

8-
use crate::core::PackageSet;
98
use crate::core::{Dependency, PackageId, Source, SourceId, SourceMap, Summary};
9+
use crate::core::{InternedString, PackageSet};
1010
use crate::sources::config::SourceConfigMap;
1111
use crate::util::errors::{CargoResult, CargoResultExt};
1212
use crate::util::{profile, CanonicalUrl, Config};
@@ -94,7 +94,7 @@ type LockedMap = HashMap<
9494
SourceId,
9595
HashMap<
9696
// This next level is keyed by the name of the package...
97-
String,
97+
InternedString,
9898
// ... and the value here is a list of tuples. The first element of each
9999
// tuple is a package which has the source/name used to get to this
100100
// point. The second element of each tuple is the list of locked
@@ -207,9 +207,7 @@ impl<'cfg> PackageRegistry<'cfg> {
207207
.locked
208208
.entry(id.source_id())
209209
.or_insert_with(HashMap::new);
210-
let sub_vec = sub_map
211-
.entry(id.name().to_string())
212-
.or_insert_with(Vec::new);
210+
let sub_vec = sub_map.entry(id.name()).or_insert_with(Vec::new);
213211
sub_vec.push((id, deps));
214212
}
215213

@@ -640,7 +638,7 @@ fn lock(
640638
) -> Summary {
641639
let pair = locked
642640
.get(&summary.source_id())
643-
.and_then(|map| map.get(&*summary.name()))
641+
.and_then(|map| map.get(&summary.name()))
644642
.and_then(|vec| vec.iter().find(|&&(id, _)| id == summary.package_id()));
645643

646644
trace!("locking summary of {}", summary.package_id());
@@ -730,7 +728,7 @@ fn lock(
730728
// If anything does then we lock it to that and move on.
731729
let v = locked
732730
.get(&dep.source_id())
733-
.and_then(|map| map.get(&*dep.package_name()))
731+
.and_then(|map| map.get(&dep.package_name()))
734732
.and_then(|vec| vec.iter().find(|&&(id, _)| dep.matches_id(id)));
735733
if let Some(&(id, _)) = v {
736734
trace!("\tsecond hit on {}", id);

0 commit comments

Comments
 (0)