-
Notifications
You must be signed in to change notification settings - Fork 1
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
Remove unsafe and unused code #2
base: main
Are you sure you want to change the base?
Conversation
// Instead of swapping one pair at the time, it is more efficient to perform a cyclic | ||
// permutation. This is not strictly equivalent to swapping, but produces a similar | ||
// result using fewer memory operations. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment should be retained.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It isn't actually true for the replacement code (which performs at least the same number of memory operations as naive swapping would). The only part that remains true is "This is not strictly equivalent to swapping", which is implied by the new comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are there any unit tests and/or benchmarks that could be brought over from the original sources to verify the correctness of this transformation, and determine how it compares in terms of runtime cost? I'm 👎 on this without more extensive tests at least.
Yes, I've added tests in #3. (Note that these don't exercise the specific nondeterministic behaviour we're trying to preserve, though, they're just the tests from the stdlib.) |
Signed-off-by: Daira Hopwood <[email protected]>
542b0fa
to
8fdefaf
Compare
fixes #1