File tree 1 file changed +3
-22
lines changed
1 file changed +3
-22
lines changed Original file line number Diff line number Diff line change @@ -2476,28 +2476,9 @@ macro_rules! int_impl {
2476
2476
if self <= 0 || base <= 1 {
2477
2477
None
2478
2478
} else {
2479
- let mut n = 0 ;
2480
- let mut r = 1 ;
2481
-
2482
- // Optimization for 128 bit wide integers.
2483
- if Self :: BITS == 128 {
2484
- // The following is a correct lower bound for ⌊log(base,self)⌋ because
2485
- //
2486
- // log(base,self) = log(2,self) / log(2,base)
2487
- // ≥ ⌊log(2,self)⌋ / (⌊log(2,base)⌋ + 1)
2488
- //
2489
- // hence
2490
- //
2491
- // ⌊log(base,self)⌋ ≥ ⌊ ⌊log(2,self)⌋ / (⌊log(2,base)⌋ + 1) ⌋ .
2492
- n = self . ilog2( ) / ( base. ilog2( ) + 1 ) ;
2493
- r = base. pow( n) ;
2494
- }
2495
-
2496
- while r <= self / base {
2497
- n += 1 ;
2498
- r *= base;
2499
- }
2500
- Some ( n)
2479
+ // Delegate to the unsigned implementation.
2480
+ // The condition makes sure that both casts are exact.
2481
+ ( self as $UnsignedT) . checked_ilog( base as $UnsignedT)
2501
2482
}
2502
2483
}
2503
2484
You can’t perform that action at this time.
0 commit comments