diff options
| author | Jakub Beránek <berykubik@gmail.com> | 2025-06-20 20:03:24 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-06-20 20:03:24 +0200 |
| commit | 74cea635e1b14337acd5c06d8b21a24f01e5002e (patch) | |
| tree | ee9ce5eca854689793fe1cf51e83a0a41ce7ec36 /library/alloc | |
| parent | 64a7fcf26ec6bf4e0629f44ed74fb9fbd5ffe95b (diff) | |
| parent | 88f1ed4871887db8b4d96688480bf96666d82005 (diff) | |
| download | rust-74cea635e1b14337acd5c06d8b21a24f01e5002e.tar.gz rust-74cea635e1b14337acd5c06d8b21a24f01e5002e.zip | |
Rollup merge of #142764 - ChaiTRex:ilog_10_to_ilog10, r=workingjubilee
Convert `ilog(10)` to `ilog10()` Except in tests, convert `integer.ilog(10)` to `integer.ilog10()` for better speed and to provide better examples of code that efficiently counts decimal digits. I couldn't find any instances of `integer.ilog(2)`.
Diffstat (limited to 'library/alloc')
| -rw-r--r-- | library/alloc/src/string.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/library/alloc/src/string.rs b/library/alloc/src/string.rs index 5197e40764b..c200a92e1bd 100644 --- a/library/alloc/src/string.rs +++ b/library/alloc/src/string.rs @@ -2841,7 +2841,7 @@ macro_rules! impl_to_string { impl SpecToString for $signed { #[inline] fn spec_to_string(&self) -> String { - const SIZE: usize = $signed::MAX.ilog(10) as usize + 1; + const SIZE: usize = $signed::MAX.ilog10() as usize + 1; let mut buf = [core::mem::MaybeUninit::<u8>::uninit(); SIZE]; // Only difference between signed and unsigned are these 8 lines. let mut out; @@ -2861,7 +2861,7 @@ macro_rules! impl_to_string { impl SpecToString for $unsigned { #[inline] fn spec_to_string(&self) -> String { - const SIZE: usize = $unsigned::MAX.ilog(10) as usize + 1; + const SIZE: usize = $unsigned::MAX.ilog10() as usize + 1; let mut buf = [core::mem::MaybeUninit::<u8>::uninit(); SIZE]; self._fmt(&mut buf).to_string() |
