Skip to content

Conversation

@ghuls
Copy link

@ghuls ghuls commented Jan 27, 2026

Rewrite all functions in sorts.rs to use zipped iterators to iterate over multiple vectors, instead of using indexing operations to get the values.

When using indexing operations into vectors, the rust compiler will do bound checks to see if it is not indexing past the end of the vector.

By first check that all input vectors have the same length, and by using zipped iterators over the vectors the rust compiler can elide all those bound checks and should be able to generate faster code.

ghuls added 2 commits January 27, 2026 14:21
Add assert checks for checking if input vectors have the same length.
This will help the rust compiler later to elide bound checks.
Use zipped iterators instead of indexing to elide bound checks.
@endrebak
Copy link
Collaborator

Do you have benchmarks that show that this is faster? Just curious

@ghuls
Copy link
Author

ghuls commented Jan 28, 2026

No, I don't have a benchmark that shows a real difference, but I assume the difference will be hardly noticeable as currently sorting input/output will probably dominate most of the running time.

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