Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(73)

Unified Diff: src/base/utils/random-number-generator.cc

Issue 2040953002: [rng] improve RNG seed. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/base/utils/random-number-generator.cc
diff --git a/src/base/utils/random-number-generator.cc b/src/base/utils/random-number-generator.cc
index ff428402b6b7c92faf4dab6cb8569458606ade32..3a6f2c63cf96c845802f1e0ae0d86a161e3c38fb 100644
--- a/src/base/utils/random-number-generator.cc
+++ b/src/base/utils/random-number-generator.cc
@@ -124,10 +124,10 @@ int RandomNumberGenerator::Next(int bits) {
void RandomNumberGenerator::SetSeed(int64_t seed) {
- if (seed == 0) seed = 1;
initial_seed_ = seed;
state0_ = MurmurHash3(bit_cast<uint64_t>(seed));
- state1_ = MurmurHash3(state0_);
+ state1_ = MurmurHash3(~state0_);
+ CHECK(state0_ != 0 || state1_ != 0);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698