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

Remove unsafe and unused code #2

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

daira
Copy link
Contributor

@daira daira commented Feb 25, 2023

fixes #1

@daira daira added the enhancement New feature or request label Feb 25, 2023
Comment on lines -371 to -373
// 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.

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.

Copy link
Contributor Author

@daira daira Feb 25, 2023

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.

Copy link

@nuttycom nuttycom left a 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.

@daira
Copy link
Contributor Author

daira commented Feb 25, 2023

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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove unsafe code
2 participants