[poppler] goo/grandom.cc

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sun Sep 30 20:55:22 UTC 2018


 goo/grandom.cc |    9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

New commits:
commit 2cbdd1543134bf256ba49dd1209deadcfc45a4fe
Author: Adam Reichold <adam.reichold at t-online.de>
Date:   Sat Sep 29 09:53:20 2018 +0200

    Do not use unsigned char to instantiate a random engine as the standard permits only short and wider and MSVC is strict about that.

diff --git a/goo/grandom.cc b/goo/grandom.cc
index a9a28a59..dfecbe7a 100644
--- a/goo/grandom.cc
+++ b/goo/grandom.cc
@@ -17,11 +17,7 @@ namespace
 
 auto& grandom_engine()
 {
-  static thread_local std::independent_bits_engine<std::default_random_engine, std::numeric_limits<Guchar>::digits, Guchar> engine{
-    std::default_random_engine{
-      std::random_device{}()
-    }
-  };
+  static thread_local std::default_random_engine engine{std::random_device{}()};
   return engine;
 }
 
@@ -30,8 +26,9 @@ auto& grandom_engine()
 void grandom_fill(Guchar *buff, int size)
 {
   auto& engine = grandom_engine();
+  std::uniform_int_distribution<unsigned short> distribution{std::numeric_limits<Guchar>::min(), std::numeric_limits<Guchar>::max()};
   for (int index = 0; index < size; ++index) {
-    buff[index] = engine();
+    buff[index] = distribution(engine);
   }
 }
 


More information about the poppler mailing list