crlib: replace random number generator with wyhash.

Benchmarks shows about 4x increased PRNG perfomance increase comparing to old one. Should slightly reduce per-bot CPU usage.
This commit is contained in:
ds 2020-09-29 19:23:26 +03:00
commit 726ea72965
13 changed files with 189 additions and 179 deletions

View file

@ -272,8 +272,10 @@ public:
}
void shuffle () {
for (size_t i = length_; i >= 1; --i) {
cr::swap (contents_[i - 1], contents_[rg.int_ (i, length_ - 2)]);
int32 shuffleLength = length <int32> ();
for (int32 i = shuffleLength; i >= 1; --i) {
cr::swap (contents_[i - 1], contents_[rg.get (i, shuffleLength - 2)]);
}
}
@ -352,11 +354,11 @@ public:
}
const T &random () const {
return contents_[rg.int_ <size_t> (0, length_ - 1)];
return contents_[rg.get (0, length <int32> () - 1)];
}
T &random () {
return contents_[rg.int_ <size_t> (0u, length_ - 1u)];
return contents_[rg.get (0, length <int32> () - 1)];
}
T *data () {