Skip to content

Commit

Permalink
Auto merge of #124294 - tspiteri:ilog-first-iter, r=the8472
Browse files Browse the repository at this point in the history
Unroll first iteration of checked_ilog loop

This follows the optimization of #115913. As shown in rust-lang/rust#115913 (comment), the performance was improved in all important cases, but some regressions were introduced for the benchmarks `u32_log_random_small`, `u8_log_random` and `u8_log_random_small`.

Basically, #115913 changed the implementation from one division per iteration to one multiplication per iteration plus one division. When there are zero iterations, this is a regression from zero divisions to one division.

This PR avoids this by avoiding the division if we need zero iterations by returning `Some(0)` early. It also reduces the number of multiplications by one in all other cases.
  • Loading branch information
bors committed Jun 2, 2024
2 parents 37afc39 + 48f8a31 commit 52c47cb
Showing 0 changed files with 0 additions and 0 deletions.

0 comments on commit 52c47cb

Please sign in to comment.