Skip to content

Minor fixes to std::rand #10015

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 23, 2013
Merged

Minor fixes to std::rand #10015

merged 3 commits into from
Oct 23, 2013

Conversation

huonw
Copy link
Member

@huonw huonw commented Oct 22, 2013

  • Use "nothing up my sleeve numbers" for the ISAAC tests.
  • Replace the default implementation of Rng.fill_bytes with something that doesn't try to do bad things with transmute and vectors just for the sake of a little speed.
  • Replace the transmutes used to seed the ISAAC RNGs with calls into vec::raw.

huonw added 3 commits October 23, 2013 11:50
The `&[u8]` -> `&[u64]` and `&[u32]` casts were not nice: they ignored
alignment requirements and are generally very unsafe.
There's no value in using the "random" numbers, when nothing up your
sleeve numbers are perfectly serviceable.

http://en.wikipedia.org/wiki/Nothing_up_my_sleeve_number
Slice transmutes are now (and, really, always were) dangerous, so we
avoid them and do the (only?) non-(undefined behaviour in C) pointer
cast: casting to *u8.
bors added a commit that referenced this pull request Oct 23, 2013
- Use ["nothing up my sleeve numbers"](http://en.wikipedia.org/wiki/Nothing_up_my_sleeve_number) for the ISAAC tests.
- Replace the default implementation of `Rng.fill_bytes` with something that doesn't try to do bad things with `transmute` and vectors just for the sake of a little speed.
- Replace the transmutes used to seed the ISAAC RNGs with calls into `vec::raw`.
@bors bors closed this Oct 23, 2013
@bors bors merged commit 6e7bbda into rust-lang:master Oct 23, 2013
@huonw huonw deleted the minor-fixes branch November 25, 2013 10:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants