Bug 18217 – Don't repeatedly call unpredictableSeed to initialize rndGen
Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2018-01-09T20:07:22Z
Last change time
2018-01-09T22:30:37Z
Assigned to
No Owner
Creator
Nathan S.
Comments
Comment #0 by n8sh.secondary — 2018-01-09T20:07:22Z
The offending code in std.random:
```
static if (isSeedable!(Random, typeof(map!((a) => unpredictableSeed)(repeat(0)))))
result.seed(map!((a) => unpredictableSeed)(repeat(0)));
```
Having this code in Phobos leads others to mistakenly copy it since
Phobos is generally a model of good D programming practices.
Calling unpredictableSeed just once would be faster and would give
a better result. See comment for an explanation:
https://github.com/dlang/phobos/pull/5788#discussion_r146110307
Comment #1 by github-bugzilla — 2018-01-09T22:30:36Z