-
Notifications
You must be signed in to change notification settings - Fork 288
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
refactor: Use merge_sort
instead of qsort
for sorting.
#2638
base: master
Are you sure you want to change the base?
Conversation
6358d6c
to
ce3a61b
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2638 +/- ##
==========================================
+ Coverage 73.04% 73.16% +0.11%
==========================================
Files 149 149
Lines 30516 30594 +78
==========================================
+ Hits 22290 22383 +93
+ Misses 8226 8211 -15 ☔ View full report in Codecov by Sentry. |
5580dfc
to
d875693
Compare
What are the advantages of merge sort over qsort in this instance? |
I guess I can explain more in that comment if needed. This PR is part of my attempt to make toxcore C code rely less on struct layouts and low level system properties and be semantically simpler. I know C coders like to bit-twiddle everything, but I think it's worth trying to avoid that as much as possible. |
As for why merge sort instead of any other algorithm: it's an easy one to implement and has deterministic time complexity. If we have a lot of mostly-sorted arrays, we should probably just sorted-insert elements rather than adding a bunch of unsorted elements and sorting afterwards. |
a17e42d
to
37be3ea
Compare
This change is