MCPcopy Create free account
hub / github.com/apache/brpc / fast_rand_in_u64

Function fast_rand_in_u64

src/butil/fast_rand.cpp:141–159  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

139}
140
141uint64_t fast_rand_in_u64(uint64_t min, uint64_t max) {
142 if (need_init(_tls_seed)) {
143 init_fast_rand_seed(&_tls_seed);
144 }
145 if (min >= max) {
146 if (min == max) {
147 return min;
148 }
149 const uint64_t tmp = min;
150 min = max;
151 max = tmp;
152 }
153 uint64_t range = max - min + 1;
154 if (range == 0) {
155 // max = UINT64_MAX, min = UINT64_MIN
156 return xorshift128_next(&_tls_seed);
157 }
158 return min + fast_rand_impl(range, &_tls_seed);
159}
160
161inline double fast_rand_double(FastRandSeed* seed) {
162 // Copied from rand_util.cc

Callers 1

fast_rand_inFunction · 0.85

Calls 4

need_initFunction · 0.85
init_fast_rand_seedFunction · 0.85
xorshift128_nextFunction · 0.85
fast_rand_implFunction · 0.85

Tested by

no test coverage detected