Skip to content

Commit 542536b

Browse files
committed
dont need to copy this string
1 parent fe0e5a4 commit 542536b

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/cargo/sources/registry/index.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -210,12 +210,10 @@ enum MaybeIndexSummary {
210210

211211
/// A parsed representation of a summary from the index.
212212
///
213-
/// In addition to a full `Summary` we have a few auxiliary pieces of
214-
/// information liked `yanked` and what the checksum hash is.
213+
/// In addition to a full `Summary` we have information on whether it is `yanked`.
215214
pub struct IndexSummary {
216215
pub summary: Summary,
217216
pub yanked: bool,
218-
pub hash: String,
219217
}
220218

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

244242
/// Returns the hash listed for a specified `PackageId`.
245-
pub fn hash(&mut self, pkg: PackageId, load: &mut dyn RegistryData) -> CargoResult<String> {
243+
pub fn hash(&mut self, pkg: PackageId, load: &mut dyn RegistryData) -> CargoResult<&str> {
246244
let req = VersionReq::exact(pkg.version());
247245
let summary = self
248246
.summaries(pkg.name(), &req, load)?
249247
.next()
250248
.ok_or_else(|| internal(format!("no hash listed for {}", pkg)))?;
251-
Ok(summary.hash.clone())
249+
summary
250+
.summary
251+
.checksum()
252+
.ok_or_else(|| internal(format!("no hash listed for {}", pkg)))
252253
}
253254

254255
/// Load a list of summaries for `name` package in this registry which
@@ -722,11 +723,10 @@ impl IndexSummary {
722723
.map(|dep| dep.into_dep(source_id))
723724
.collect::<CargoResult<Vec<_>>>()?;
724725
let mut summary = Summary::new(pkgid, deps, &features, links, false)?;
725-
summary.set_checksum(cksum.clone());
726+
summary.set_checksum(cksum);
726727
Ok(IndexSummary {
727728
summary,
728729
yanked: yanked.unwrap_or(false),
729-
hash: cksum,
730730
})
731731
}
732732
}

0 commit comments

Comments
 (0)