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

Unified Diff: runtime/lib/math_patch.dart

Issue 200483003: - Do not rely on time to seed the default PRNG. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 9 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
Index: runtime/lib/math_patch.dart
===================================================================
--- runtime/lib/math_patch.dart (revision 33702)
+++ runtime/lib/math_patch.dart (working copy)
@@ -154,13 +154,11 @@
static const _A = 0xffffda61;
// Use a singleton Random object to get a new seed if no seed was passed.
- static var _prng = null;
+ static var _prng = new Random(_initialSeed());
siva 2014/03/17 17:46:02 This can potentially result in an overflow error w
+ static int _initialSeed() native "Random_initialSeed";
+
static int _nextSeed() {
- if (_prng == null) {
- // TODO(iposva): Use system to get a random seed.
- _prng = new Random(new DateTime.now().millisecondsSinceEpoch);
- }
// Trigger the PRNG once to change the internal state.
_prng._nextState();
return _prng._state[kSTATE_LO];
« runtime/lib/math.cc ('K') | « runtime/lib/math.cc ('k') | runtime/vm/bootstrap_natives.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698