Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

don't need to copy this string #7324

Merged
merged 1 commit into from
Sep 4, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/cargo/sources/registry/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,12 +210,10 @@ enum MaybeIndexSummary {

/// A parsed representation of a summary from the index.
///
/// In addition to a full `Summary` we have a few auxiliary pieces of
/// information liked `yanked` and what the checksum hash is.
/// In addition to a full `Summary` we have information on whether it is `yanked`.
pub struct IndexSummary {
pub summary: Summary,
pub yanked: bool,
pub hash: String,
}

/// A representation of the cache on disk that Cargo maintains of summaries.
Expand All @@ -242,13 +240,16 @@ impl<'cfg> RegistryIndex<'cfg> {
}

/// Returns the hash listed for a specified `PackageId`.
pub fn hash(&mut self, pkg: PackageId, load: &mut dyn RegistryData) -> CargoResult<String> {
pub fn hash(&mut self, pkg: PackageId, load: &mut dyn RegistryData) -> CargoResult<&str> {
let req = VersionReq::exact(pkg.version());
let summary = self
.summaries(pkg.name(), &req, load)?
.next()
.ok_or_else(|| internal(format!("no hash listed for {}", pkg)))?;
Ok(summary.hash.clone())
summary
.summary
.checksum()
.ok_or_else(|| internal(format!("no hash listed for {}", pkg)))
}

/// Load a list of summaries for `name` package in this registry which
Expand Down Expand Up @@ -722,11 +723,10 @@ impl IndexSummary {
.map(|dep| dep.into_dep(source_id))
.collect::<CargoResult<Vec<_>>>()?;
let mut summary = Summary::new(pkgid, deps, &features, links, false)?;
summary.set_checksum(cksum.clone());
summary.set_checksum(cksum);
Ok(IndexSummary {
summary,
yanked: yanked.unwrap_or(false),
hash: cksum,
})
}
}
Expand Down