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 qsort #27

Merged
merged 4 commits into from
Mar 29, 2024
Merged

add qsort #27

merged 4 commits into from
Mar 29, 2024

Conversation

gmmyung
Copy link
Contributor

@gmmyung gmmyung commented Mar 26, 2024

Most part of the source code is copied from relibc, which is under MIT license.

src/qsort.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@jonathanpallant jonathanpallant left a comment

Choose a reason for hiding this comment

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

Couple of small notes. But also, can you run cargo-tarpaulin on this and check we have good coverage? We have a lot of large, complex, undocumented functions here and we should really check they all work correctly no matter what input they are given. For example, I suspect we don’t hit the recursion limit? It may also make sense to unit test the helper functions.

@jonathanpallant
Copy link
Collaborator

Plus I don’t understand the failure on beta. Any ideas?

@gmmyung
Copy link
Contributor Author

gmmyung commented Mar 26, 2024

Plus I don’t understand the failure on beta. Any ideas?

It seems like stable rust doesn't not have runtime checks on copy_from_nonoverlapping.
https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=7a8fae6d1301cfc983e9fe9d853e00e3

Maybe this should be also fixed in upstream relibc.

@gmmyung
Copy link
Contributor Author

gmmyung commented Mar 27, 2024

Added tests for more coverage. The coverage is at 96%, but testing the fallback to heapsort when we hit max_depth is tough to reach.

src/qsort.rs Outdated Show resolved Hide resolved
@thejpster
Copy link
Member

I have some ideas to make this much safer, basically operating entirely on indicies and only dealing with pointers when items have to be compared or swapped. But I see no reason for that to block this.

@thejpster thejpster added this pull request to the merge queue Mar 29, 2024
Merged via the queue into rust-embedded-community:master with commit f186c38 Mar 29, 2024
13 checks passed
@gmmyung gmmyung deleted the qsort branch March 29, 2024 21:06
@gmmyung gmmyung restored the qsort branch June 7, 2024 10:20
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.

3 participants