diff options
author | Björn Gustavsson <[email protected]> | 2015-12-04 12:15:40 +0100 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2015-12-11 14:37:46 +0100 |
commit | 80757f9491c72ee262a5910e0b3b02e95b1e5f2a (patch) | |
tree | 1019a6da73ac28571a0b51727ed6fa33daf11522 /lib/compiler/src | |
parent | dee396ffd32dcd68c47cab983c75ba32f921b9db (diff) | |
download | otp-80757f9491c72ee262a5910e0b3b02e95b1e5f2a.tar.gz otp-80757f9491c72ee262a5910e0b3b02e95b1e5f2a.tar.bz2 otp-80757f9491c72ee262a5910e0b3b02e95b1e5f2a.zip |
Use 'rand' instead of the obsolete 'random' module
In most cases, we don't have to seed the random number generator,
as the rand:uniform/1 takes care about that itself.
Diffstat (limited to 'lib/compiler/src')
-rw-r--r-- | lib/compiler/src/rec_env.erl | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/compiler/src/rec_env.erl b/lib/compiler/src/rec_env.erl index 0e9e12d1ad..5a4a870769 100644 --- a/lib/compiler/src/rec_env.erl +++ b/lib/compiler/src/rec_env.erl @@ -598,7 +598,16 @@ start_range(Env) -> %% (pseudo-)randomly distributed over the range. generate(_N, Range) -> - random:uniform(Range). % works well + %% We must use the same sequence of random variables to ensure + %% that two compilations of the same source code generates the + %% same BEAM code. + case rand:export_seed() of + undefined -> + rand:seed(exsplus, {1,42,2053}); + _ -> + ok + end, + rand:uniform(Range). % works well %% ===================================================================== |