libstdc++: Optimize uniform_int_distribution using Lemire's algorithm
authorDaniel Lemire <lemire@gmail.com>
Fri, 9 Oct 2020 13:09:36 +0000 (14:09 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Fri, 9 Oct 2020 13:09:36 +0000 (14:09 +0100)
commit98c37d3bacbb2f8bbbe56ed53a9547d3be01b66b
tree072d00b35158c00d6488a97790c217d4bb27b563
parent6ce2cb116af6e0965ff0dd69e7fd1925cf5dc68c
libstdc++: Optimize uniform_int_distribution using Lemire's algorithm

Co-authored-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:

* include/bits/uniform_int_dist.h (uniform_int_distribution::_S_nd):
New member function implementing Lemire's "nearly divisionless"
algorithm.
(uniform_int_distribution::operator()): Use _S_nd when the range
of the URBG is the full width of the result type.
libstdc++-v3/include/bits/uniform_int_dist.h