Skip to content

Commit

Permalink
dont need to copy this string
Browse files Browse the repository at this point in the history
  • Loading branch information
Eh2406 committed Sep 4, 2019
1 parent fe0e5a4 commit 542536b
Showing 1 changed file with 7 additions and 7 deletions.
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

0 comments on commit 542536b

Please sign in to comment.