crypto: replace CountBits with std::bit_width

bit_width is a drop-in replacement with an exact meaning in c++, so there is
no need to continue testing/fuzzing/benchmarking.
This commit is contained in:
Cory Fields
2023-12-12 18:44:49 +00:00
parent 52f9bba889
commit 297367b3bb
5 changed files with 5 additions and 34 deletions

View File

@@ -11,6 +11,7 @@
#include <span.h>
#include <uint256.h>
#include <bit>
#include <cassert>
#include <chrono>
#include <cstdint>
@@ -203,7 +204,7 @@ public:
{
assert(range);
--range;
int bits = CountBits(range);
int bits = std::bit_width(range);
while (true) {
uint64_t ret = randbits(bits);
if (ret <= range) return ret;