mirror of
https://github.com/rust-lang/rust
synced 2024-10-14 12:33:57 +00:00
unroll first iter of checked_ilog loop to save one multiplication
This commit is contained in:
parent
c67277301c
commit
3b2436c136
|
@ -1093,9 +1093,12 @@ pub const fn ilog10(self) -> u32 {
|
|||
pub const fn checked_ilog(self, base: Self) -> Option<u32> {
|
||||
if self <= 0 || base <= 1 {
|
||||
None
|
||||
} else if self < base {
|
||||
Some(0)
|
||||
} else {
|
||||
let mut n = 0;
|
||||
let mut r = 1;
|
||||
// Since base >= self, n >= 1
|
||||
let mut n = 1;
|
||||
let mut r = base;
|
||||
|
||||
// Optimization for 128 bit wide integers.
|
||||
if Self::BITS == 128 {
|
||||
|
|
Loading…
Reference in a new issue