pep440-rs: don't allocate when retrieving a version number

It's not clear whether these routines are used in any hot path so I
don't know whether this will have a perf improvement, but there's really
no reason not to do this.
This commit is contained in:
Andrew Gallant 2023-11-10 13:50:59 -05:00
parent 1deea745b5
commit 259a835ab6
No known key found for this signature in database
GPG Key ID: 5518C8B38E0693E0
1 changed files with 3 additions and 3 deletions

View File

@ -355,17 +355,17 @@ impl PyVersion {
#[getter]
#[allow(clippy::get_first)]
pub fn major(&self) -> u32 {
self.release().get(0).copied().unwrap_or_default()
self.0.release.get(0).copied().unwrap_or_default()
}
/// The second item of release or 0 if unavailable.
#[getter]
pub fn minor(&self) -> u32 {
self.release().get(1).copied().unwrap_or_default()
self.0.release.get(1).copied().unwrap_or_default()
}
/// The third item of release or 0 if unavailable.
#[getter]
pub fn micro(&self) -> u32 {
self.release().get(2).copied().unwrap_or_default()
self.0.release.get(2).copied().unwrap_or_default()
}
/// Parses a PEP 440 version string