www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18217] New: Don't repeatedly call unpredictableSeed to

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 puremagic.com
          Reporter: n8sh.secondary 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

--
Jan 09