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
Commits pushed to master at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/befc9896d0f699163e6c252771ef3f4234b48f3b Fix Issue 18217: Don't repeatedly call unpredictableSeed to initialize rndGen Explanation: https://github.com/dlang/phobos/pull/5788#discussion_r146110307 https://github.com/dlang/phobos/commit/6fe220f6f2cf6d475c881e9105c6821961281789 Merge pull request #6021 from n8sh/rndGen-seeding Fix Issue 18217: Don't repeatedly call unpredictableSeed to initialize rndGen merged-on-behalf-of: Sebastian Wilzbach <[email protected]>