QRandomGenerator: Enforce the use of 32-bit integers in the engine

std::mt19937 is defined as operating on uint_fast32_t, which is usually
just a 32-bit integer. That's not the case on 64-bit Linux, where it is
actually 64-bit wide, meaning sizeof(std::mt19937) jumps from 2504 to
5000 bytes, with exactly 50% of it filled with zeroes. The seed()
function also needs a large zero-extending loop.

Change-Id: Icaa86fc7b54d4b368c0efffd14efa911e2a40b44
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This commit is contained in:
Thiago Macieira 2017-10-21 11:24:54 -07:00
parent bb3872d609
commit 3c7a6a7a58

View File

@ -177,7 +177,8 @@ private:
friend class QRandomGenerator64;
struct SystemGenerator;
struct SystemAndGlobalGenerators;
typedef std::mt19937 RandomEngine;
using RandomEngine = std::mersenne_twister_engine<quint32,
32,624,397,31,0x9908b0df,11,0xffffffff,7,0x9d2c5680,15,0xefc60000,18,1812433253>;
union Storage {
uint dummy;