mirror of
https://github.com/astral-sh/uv.git
synced 2025-11-11 08:32:41 +00:00
Shrink Dist from 352 to 288 bytes (#10389)
Found this when looking at #10385. Since we're constructing a lot of `Dist`s, we should keep it small.
This commit is contained in:
parent
15c81e9a02
commit
c5583b326f
4 changed files with 7 additions and 7 deletions
|
|
@ -21,7 +21,7 @@ async fn remote_metadata_with_and_without_cache() -> Result<()> {
|
||||||
let filename = WheelFilename::from_str(url.rsplit_once('/').unwrap().1)?;
|
let filename = WheelFilename::from_str(url.rsplit_once('/').unwrap().1)?;
|
||||||
let dist = BuiltDist::DirectUrl(DirectUrlBuiltDist {
|
let dist = BuiltDist::DirectUrl(DirectUrlBuiltDist {
|
||||||
filename,
|
filename,
|
||||||
location: Url::parse(url).unwrap(),
|
location: Box::new(Url::parse(url).unwrap()),
|
||||||
url: VerbatimUrl::from_str(url).unwrap(),
|
url: VerbatimUrl::from_str(url).unwrap(),
|
||||||
});
|
});
|
||||||
let capabilities = IndexCapabilities::default();
|
let capabilities = IndexCapabilities::default();
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ pub(crate) async fn wheel_metadata(args: WheelMetadataArgs) -> Result<()> {
|
||||||
.wheel_metadata(
|
.wheel_metadata(
|
||||||
&BuiltDist::DirectUrl(DirectUrlBuiltDist {
|
&BuiltDist::DirectUrl(DirectUrlBuiltDist {
|
||||||
filename,
|
filename,
|
||||||
location: archive.url,
|
location: Box::new(archive.url),
|
||||||
url: args.url,
|
url: args.url,
|
||||||
}),
|
}),
|
||||||
&capabilities,
|
&capabilities,
|
||||||
|
|
|
||||||
|
|
@ -250,7 +250,7 @@ pub struct DirectUrlBuiltDist {
|
||||||
/// `https://example.org/packages/flask-3.0.0-py3-none-any.whl`
|
/// `https://example.org/packages/flask-3.0.0-py3-none-any.whl`
|
||||||
pub filename: WheelFilename,
|
pub filename: WheelFilename,
|
||||||
/// The URL without the subdirectory fragment.
|
/// The URL without the subdirectory fragment.
|
||||||
pub location: Url,
|
pub location: Box<Url>,
|
||||||
/// The URL as it was provided by the user.
|
/// The URL as it was provided by the user.
|
||||||
pub url: VerbatimUrl,
|
pub url: VerbatimUrl,
|
||||||
}
|
}
|
||||||
|
|
@ -363,7 +363,7 @@ impl Dist {
|
||||||
|
|
||||||
Ok(Self::Built(BuiltDist::DirectUrl(DirectUrlBuiltDist {
|
Ok(Self::Built(BuiltDist::DirectUrl(DirectUrlBuiltDist {
|
||||||
filename,
|
filename,
|
||||||
location,
|
location: Box::new(location),
|
||||||
url,
|
url,
|
||||||
})))
|
})))
|
||||||
}
|
}
|
||||||
|
|
@ -1343,8 +1343,8 @@ mod test {
|
||||||
/// Ensure that we don't accidentally grow the `Dist` sizes.
|
/// Ensure that we don't accidentally grow the `Dist` sizes.
|
||||||
#[test]
|
#[test]
|
||||||
fn dist_size() {
|
fn dist_size() {
|
||||||
assert!(size_of::<Dist>() <= 352, "{}", size_of::<Dist>());
|
assert!(size_of::<Dist>() <= 288, "{}", size_of::<Dist>());
|
||||||
assert!(size_of::<BuiltDist>() <= 352, "{}", size_of::<BuiltDist>());
|
assert!(size_of::<BuiltDist>() <= 288, "{}", size_of::<BuiltDist>());
|
||||||
assert!(
|
assert!(
|
||||||
size_of::<SourceDist>() <= 264,
|
size_of::<SourceDist>() <= 264,
|
||||||
"{}",
|
"{}",
|
||||||
|
|
|
||||||
|
|
@ -1820,7 +1820,7 @@ impl Package {
|
||||||
});
|
});
|
||||||
let direct_dist = DirectUrlBuiltDist {
|
let direct_dist = DirectUrlBuiltDist {
|
||||||
filename,
|
filename,
|
||||||
location: url.clone(),
|
location: Box::new(url.clone()),
|
||||||
url: VerbatimUrl::from_url(url),
|
url: VerbatimUrl::from_url(url),
|
||||||
};
|
};
|
||||||
let built_dist = BuiltDist::DirectUrl(direct_dist);
|
let built_dist = BuiltDist::DirectUrl(direct_dist);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue