Use boxed slices for hash vector (#11714)

## Summary

We never resize these, and they're stored everywhere (on `File`, etc.).
Seems useful to use a more efficient structure for them.
This commit is contained in:
Charlie Marsh 2025-02-24 07:11:44 -10:00 committed by GitHub
parent d4a0096c14
commit 21f4b0863d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
23 changed files with 264 additions and 139 deletions

View file

@ -201,12 +201,15 @@ impl VersionMap {
}
/// Return the [`Hashes`] for the given version, if any.
pub(crate) fn hashes(&self, version: &Version) -> Option<Vec<HashDigest>> {
pub(crate) fn hashes(&self, version: &Version) -> Option<&[HashDigest]> {
match self.inner {
VersionMapInner::Eager(ref eager) => {
eager.map.get(version).map(|file| file.hashes().to_vec())
}
VersionMapInner::Lazy(ref lazy) => lazy.get(version).map(|file| file.hashes().to_vec()),
VersionMapInner::Eager(ref eager) => eager
.map
.get(version)
.map(uv_distribution_types::PrioritizedDist::hashes),
VersionMapInner::Lazy(ref lazy) => lazy
.get(version)
.map(uv_distribution_types::PrioritizedDist::hashes),
}
}
@ -422,7 +425,7 @@ impl VersionMapLazy {
&filename,
&filename.name,
&filename.version,
&hashes,
hashes.as_slice(),
yanked,
excluded,
upload_time,
@ -438,7 +441,7 @@ impl VersionMapLazy {
let compatibility = self.source_dist_compatibility(
&filename.name,
&filename.version,
&hashes,
hashes.as_slice(),
yanked,
excluded,
upload_time,