Skip to content
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

Add functionality for generating a ByteArray #10

Merged
merged 6 commits into from
Feb 25, 2020

Conversation

lehins
Copy link
Collaborator

@lehins lehins commented Feb 23, 2020

Here is an interface and default implementation for generating a sequence of bytes as a ByteArray

I mentioned this briefly in #5 (comment)

System/Random.hs Outdated
Comment on lines 270 to 271
-- in order not to mess up the byte order we write generated Word64 into a temporary
-- pointer and then copy only the missing bytes over to the array
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A previous iteration of this code used uniformWord8 to generate those remaining bytes. Did you replace the uniformWord8 based generation for the remaining bytes by uniformWord64 based generation because of byte order?

If that is the case, I think this comment could be even more explicit: "... we write generated Word64 instead of generating Word8 one by one ..." or something like that.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was not only byte order. Generating 1xWord64 and 8x Word8 concatenated together will always give you different result, because in order generate 8x Word8 we need to generate 8x Word64 first (at least in case of splitmix)

I'll add a more descriptive comment to the function

@lehins
Copy link
Collaborator Author

lehins commented Feb 25, 2020

I also added helper functions for generating ByteString, which I am sure will come in handy.

@lehins lehins merged commit 200143c into interface-to-performance Feb 25, 2020
@curiousleo curiousleo deleted the bytearray branch March 17, 2020 09:56
curiousleo pushed a commit that referenced this pull request May 19, 2020
Add functionality for generating a ByteArray
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