Improve C++ SHR3 implementation, including discard function.