diff options
author | Pieter Wuille <pieter@wuille.net> | 2024-06-27 11:40:00 -0400 |
---|---|---|
committer | Pieter Wuille <pieter@wuille.net> | 2024-07-01 12:39:53 -0400 |
commit | ddc184d999d7e1a87efaf6bcb222186f0dcd87ec (patch) | |
tree | b5f108b5f86a71f952df306ef80fd6af9ee3d652 /src/random.h | |
parent | e2d1f84858485650ff743753ffa5c679f210a992 (diff) |
random: get rid of GetRand by inlining
Diffstat (limited to 'src/random.h')
-rw-r--r-- | src/random.h | 16 |
1 files changed, 1 insertions, 15 deletions
diff --git a/src/random.h b/src/random.h index afbae0cec3..1573e49ef7 100644 --- a/src/random.h +++ b/src/random.h @@ -426,20 +426,6 @@ void Shuffle(I first, I last, R&& rng) } } -/** Generate a uniform random integer of type T in the range [0..nMax) - * Precondition: nMax > 0, T is an integral type, no larger than uint64_t - */ -template<typename T> -T GetRand(T nMax) noexcept { - return T(FastRandomContext().randrange(nMax)); -} - -/** Generate a uniform random integer of type T in its entire non-negative range. */ -template<typename T> -T GetRand() noexcept { - return T(FastRandomContext().rand<T>()); -} - /** Generate a uniform random duration in the range [0..max). Precondition: max.count() > 0 */ template <typename D> D GetRandomDuration(typename std::common_type<D>::type max) noexcept @@ -448,7 +434,7 @@ D GetRandomDuration(typename std::common_type<D>::type max) noexcept // type than the function argument. So std::common_type is used to force the // call site to specify the type of the return value. { - return D{GetRand(max.count())}; + return D{FastRandomContext().randrange(max.count())}; }; constexpr auto GetRandMicros = GetRandomDuration<std::chrono::microseconds>; constexpr auto GetRandMillis = GetRandomDuration<std::chrono::milliseconds>; |