[Issue 18217] New: Don't repeatedly call unpredictableSeed to initialize rndGen
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Jan 9 20:07:22 UTC 2018
https://issues.dlang.org/show_bug.cgi?id=18217
Issue ID: 18217
Summary: Don't repeatedly call unpredictableSeed to initialize
rndGen
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: enhancement
Priority: P1
Component: phobos
Assignee: nobody at puremagic.com
Reporter: n8sh.secondary at hotmail.com
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
--
More information about the Digitalmars-d-bugs
mailing list