aboutsummaryrefslogtreecommitdiff
path: root/src/random.h
diff options
context:
space:
mode:
authorCory Fields <cory-nospam-@coryfields.com>2023-12-12 18:44:49 +0000
committerCory Fields <cory-nospam-@coryfields.com>2024-02-26 16:13:12 +0000
commit297367b3bb062c57142747719ac9bf2e12717ce9 (patch)
tree8625b675f71a88ce667006473f541709e4a83a7e /src/random.h
parent52f9bba889fd9b50a0543fd9fedc389592cdc7e5 (diff)
downloadbitcoin-297367b3bb062c57142747719ac9bf2e12717ce9.tar.xz
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.
Diffstat (limited to 'src/random.h')
-rw-r--r--src/random.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/random.h b/src/random.h
index 76bae5838d..f7c20ee4b0 100644
--- a/src/random.h
+++ b/src/random.h
@@ -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;