Remove unnecessary clones in resolver (#420)

This commit is contained in:
Charlie Marsh 2023-11-13 18:00:52 -08:00 committed by GitHub
parent 13ba4405aa
commit a20325f184
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 9 deletions

View File

@ -330,9 +330,9 @@ impl<'a, Context: BuildContext + Sync> Resolver<'a, Context> {
// Emit a request to fetch the metadata for this version. // Emit a request to fetch the metadata for this version.
if in_flight.insert_file(&candidate.file) { if in_flight.insert_file(&candidate.file) {
let distribution = Dist::from_registry( let distribution = Dist::from_registry(
candidate.package_name.clone(), candidate.package_name,
candidate.version.clone().into(), candidate.version.into(),
candidate.file.clone().into(), candidate.file.into(),
); );
request_sink.unbounded_send(Request::Dist(distribution))?; request_sink.unbounded_send(Request::Dist(distribution))?;
} }
@ -419,17 +419,18 @@ impl<'a, Context: BuildContext + Sync> Resolver<'a, Context> {
candidate.file.clone().into(), candidate.file.clone().into(),
); );
let version = candidate.version.clone();
// Emit a request to fetch the metadata for this version. // Emit a request to fetch the metadata for this version.
if in_flight.insert_file(&candidate.file) { if in_flight.insert_file(&candidate.file) {
let distribution = Dist::from_registry( let distribution = Dist::from_registry(
candidate.package_name.clone(), candidate.package_name,
candidate.version.clone().into(), candidate.version.into(),
candidate.file.clone().into(), candidate.file.into(),
); );
request_sink.unbounded_send(Request::Dist(distribution))?; request_sink.unbounded_send(Request::Dist(distribution))?;
} }
let version = candidate.version.clone();
Ok(Some(version)) Ok(Some(version))
} }
}; };
@ -559,7 +560,7 @@ impl<'a, Context: BuildContext + Sync> Resolver<'a, Context> {
} }
if let Ok(filename) = WheelFilename::from_str(file.filename.as_str()) { if let Ok(filename) = WheelFilename::from_str(file.filename.as_str()) {
if filename.is_compatible(self.tags) { if filename.is_compatible(self.tags) {
let version = PubGrubVersion::from(filename.version.clone()); let version = PubGrubVersion::from(filename.version);
match version_map.entry(version) { match version_map.entry(version) {
std::collections::btree_map::Entry::Occupied(mut entry) => { std::collections::btree_map::Entry::Occupied(mut entry) => {
if matches!(entry.get(), DistFile::Sdist(_)) { if matches!(entry.get(), DistFile::Sdist(_)) {
@ -575,7 +576,7 @@ impl<'a, Context: BuildContext + Sync> Resolver<'a, Context> {
} else if let Ok(filename) = } else if let Ok(filename) =
SourceDistFilename::parse(file.filename.as_str(), &package_name) SourceDistFilename::parse(file.filename.as_str(), &package_name)
{ {
let version = PubGrubVersion::from(filename.version.clone()); let version = PubGrubVersion::from(filename.version);
if let std::collections::btree_map::Entry::Vacant(entry) = if let std::collections::btree_map::Entry::Vacant(entry) =
version_map.entry(version) version_map.entry(version)
{ {