From 82d3c36ebdeaeb2f52e120b5fe86ea9f9b15afb0 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Thu, 12 Nov 2020 11:07:14 +1000 Subject: [PATCH] rand/xoshiro: simplify state initialisation from seed_seq --- rand/xoshiro.cpp | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/rand/xoshiro.cpp b/rand/xoshiro.cpp index 204324d7..07937dc6 100644 --- a/rand/xoshiro.cpp +++ b/rand/xoshiro.cpp @@ -39,18 +39,11 @@ xoshiro256plusplus::xoshiro256plusplus (u64 _seed) //----------------------------------------------------------------------------- xoshiro256plusplus::xoshiro256plusplus (std::seed_seq &seq) { - std::generate ( - std::begin (m_state), - std::end (m_state), - [&] (void) { - u64 parts[2]; - seq.generate ( - std::begin (parts), - std::end (parts) - ); - return parts[0] << 4 | parts[1]; - } - ); + u32 parts[8]; + seq.generate (std::begin (parts), std::end (parts)); + + for (int i = 0; i < std::ssize (m_state); ++i) + m_state[i] = u64 (parts[i * 2]) << 32 | parts[i * 2 + 1]; }