Closed as duplicate of#12894
Description
What it does
If calls to ilog
or checked_ilog
are made with a known constant 2
or 10
, suggest replacing them with the fixed-base versions ilog2
or ilog10
.
Advantage
The fixed-base versions produce more performant code https://rust.godbolt.org/z/ffjx1Gjh7
Drawbacks
No response
Example
let a = x.ilog(2)
let b = x.ilog(10);
let c = x.checked_ilog(2);
let d = x.checked_ilog(10);
Could be written as:
let a = x.ilog2()
let b = x.ilog10();
let c = x.checked_ilog2();
let d = x.checked_ilog10();