From 1467f47e36ea69c6db079df4e7233943225a348d Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Mon, 22 Dec 2025 20:44:21 -0500 Subject: [PATCH] fmt: get rid of `Decimal::end` It's not used. I believe it was being used when `Decimal` was also responsible for formatting the fractional part of a floating point number. But it isn't needed any more. --- src/fmt/util.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/fmt/util.rs b/src/fmt/util.rs index fc0ddbf..a51e39e 100644 --- a/src/fmt/util.rs +++ b/src/fmt/util.rs @@ -83,7 +83,6 @@ impl Default for DecimalFormatter { pub(crate) struct Decimal { buf: [u8; Self::MAX_LEN as usize], start: u8, - end: u8, } impl Decimal { @@ -98,11 +97,8 @@ impl Decimal { formatter: &DecimalFormatter, mut value: u64, ) -> Decimal { - let mut decimal = Decimal { - buf: [0; Self::MAX_LEN as usize], - start: Self::MAX_LEN, - end: Self::MAX_LEN, - }; + let mut decimal = + Decimal { buf: [0; Self::MAX_LEN as usize], start: Self::MAX_LEN }; loop { decimal.start -= 1; @@ -147,7 +143,7 @@ impl Decimal { /// used to represent this decimal number. #[inline] const fn len(&self) -> u8 { - self.end - self.start + Self::MAX_LEN - self.start } /// Returns the ASCII representation of this decimal as a byte slice. @@ -155,7 +151,7 @@ impl Decimal { /// The slice returned is guaranteed to be valid ASCII. #[inline] fn as_bytes(&self) -> &[u8] { - &self.buf[usize::from(self.start)..usize::from(self.end)] + &self.buf[usize::from(self.start)..] } /// Returns the ASCII representation of this decimal as a string slice.