From 3c7a6a7a581f9ea6f05a22a912d660c5402a1fa8 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sat, 21 Oct 2017 11:24:54 -0700 Subject: 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 --- src/corelib/global/qrandom.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/global/qrandom.h b/src/corelib/global/qrandom.h index bde64646a4..005de0941f 100644 --- a/src/corelib/global/qrandom.h +++ b/src/corelib/global/qrandom.h @@ -177,7 +177,8 @@ private: friend class QRandomGenerator64; struct SystemGenerator; struct SystemAndGlobalGenerators; - typedef std::mt19937 RandomEngine; + using RandomEngine = std::mersenne_twister_engine; union Storage { uint dummy; -- cgit v1.2.3