From e1e9d3676734ab094e095ac49a27a70c9e8c2835 Mon Sep 17 00:00:00 2001 From: konstin Date: Sun, 22 Mar 2026 19:07:14 +0100 Subject: [PATCH] Ablation: deactivate VersionSmall Source ref: konsti/no-version-small Base: 00d72dac7b789d1c64ed21626175b80f4a1b8f2b --- crates/uv-pep440/src/version.rs | 77 +++++---------------------------- 1 file changed, 11 insertions(+), 66 deletions(-) diff --git a/crates/uv-pep440/src/version.rs b/crates/uv-pep440/src/version.rs index 488e95c11..1c8449ff4 100644 --- a/crates/uv-pep440/src/version.rs +++ b/crates/uv-pep440/src/version.rs @@ -303,8 +303,17 @@ impl Version { R: Borrow, { Self { - inner: VersionInner::Small { - small: VersionSmall::new(), + inner: VersionInner::Full { + full: Arc::new(VersionFull { + epoch: 0, + release: vec![], + pre: None, + post: None, + dev: None, + local: LocalVersion::empty(), + min: None, + max: None, + }), }, } .with_release(release_numbers) @@ -1196,15 +1205,6 @@ impl VersionSmall { // the mask and the bit length above.) const SUFFIX_KIND_MASK: u64 = 0b1111; - #[inline] - fn new() -> Self { - Self { - _force_niche: NonZero::::MIN, - repr: Self::SUFFIX_NONE << Self::SUFFIX_VERSION_BIT_LEN, - len: 0, - } - } - #[inline] #[expect(clippy::unused_self)] fn epoch(&self) -> u64 { @@ -1985,9 +1985,6 @@ impl<'a> Parser<'a> { /// Parse a version pattern, which may be a verbatim version. fn parse_pattern(mut self) -> Result { - if let Some(vpat) = self.parse_fast() { - return Ok(vpat); - } self.bump_while(|byte| byte.is_ascii_whitespace()); self.bump_if("v"); self.parse_epoch_and_initial_release()?; @@ -2008,58 +2005,6 @@ impl<'a> Parser<'a> { Ok(self.into_pattern()) } - /// Attempts to do a "fast parse" of a version. - /// - /// This looks for versions of the form `w[.x[.y[.z]]]` while - /// simultaneously parsing numbers. This format corresponds to the - /// overwhelming majority of all version strings and can avoid most of the - /// work done in the more general parser. - /// - /// If the version string is not in the format of `w[.x[.y[.z]]]`, then - /// this returns `None`. - fn parse_fast(&self) -> Option { - let (mut prev_digit, mut cur, mut release, mut len) = (false, 0u8, [0u8; 4], 0u8); - for &byte in self.v { - if byte == b'.' { - if !prev_digit { - return None; - } - prev_digit = false; - *release.get_mut(usize::from(len))? = cur; - len += 1; - cur = 0; - } else { - let digit = byte.checked_sub(b'0')?; - if digit > 9 { - return None; - } - prev_digit = true; - cur = cur.checked_mul(10)?.checked_add(digit)?; - } - } - if !prev_digit { - return None; - } - *release.get_mut(usize::from(len))? = cur; - len += 1; - let small = VersionSmall { - _force_niche: NonZero::::MIN, - repr: (u64::from(release[0]) << 48) - | (u64::from(release[1]) << 40) - | (u64::from(release[2]) << 32) - | (u64::from(release[3]) << 24) - | (VersionSmall::SUFFIX_NONE << VersionSmall::SUFFIX_VERSION_BIT_LEN), - - len, - }; - let inner = VersionInner::Small { small }; - let version = Version { inner }; - Some(VersionPattern { - version, - wildcard: false, - }) - } - /// Parses an optional initial epoch number and the first component of the /// release part of a version number. In all cases, the first part of a /// version must be a single number, and if one isn't found, an error is base-commit: 00d72dac7b789d1c64ed21626175b80f4a1b8f2b -- 2.53.0