Commit d6470abe authored by Wayne Zhang's avatar Wayne Zhang Committed by Feng Xiao

not to use std::random_device for map.Seed(). (#3133)

* not to use std::random_device for map.Seed().

* remove include random
parent e222997c
...@@ -47,9 +47,6 @@ ...@@ -47,9 +47,6 @@
#include <google/protobuf/generated_enum_util.h> #include <google/protobuf/generated_enum_util.h>
#include <google/protobuf/map_type_handler.h> #include <google/protobuf/map_type_handler.h>
#include <google/protobuf/stubs/hash.h> #include <google/protobuf/stubs/hash.h>
#if __cpp_exceptions && LANG_CXX11
#include <random>
#endif
namespace google { namespace google {
namespace protobuf { namespace protobuf {
...@@ -922,16 +919,6 @@ class Map { ...@@ -922,16 +919,6 @@ class Map {
// Return a randomish value. // Return a randomish value.
size_type Seed() const { size_type Seed() const {
// random_device can throw, so avoid it unless we are compiling with
// exceptions enabled.
#if __cpp_exceptions && LANG_CXX11
try {
std::random_device rd;
std::knuth_b knuth(rd());
std::uniform_int_distribution<size_type> u;
return u(knuth);
} catch (...) { }
#endif
size_type s = static_cast<size_type>(reinterpret_cast<uintptr_t>(this)); size_type s = static_cast<size_type>(reinterpret_cast<uintptr_t>(this));
#if defined(__x86_64__) && defined(__GNUC__) #if defined(__x86_64__) && defined(__GNUC__)
uint32 hi, lo; uint32 hi, lo;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment