-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Does InsertionSort work as expected? #2275
Comments
I'm not sure whether the current behavior is intentional or a bug, but our I think it would be best if the behavior was consistent across different sorts. |
Deleted. Stupid stuff |
I think it would be useful to create a test class that measures the number of times an instance is swapped or compared using the comparator. Doing so would let us validate that while quick_sort behaves the same with either implementation, it does less compares/swaps in one implementation over another. Or some benchmarks. Intuitively, the current implementation seems incorrect, but in its current uses that incorrect behavior doesn't seem to affect the correctness of the calling code. |
I am unable to understand how this is not a bug? |
This is not a bug as long as nothing depends on the affected behavior. There's a high chance it's a bug in serenity, where more parts of the system depend on that code, whereas the only place we use it in Ladybird is quicksort, and that doesn't depend on this function actually not writing outside of the provided bounds. However, I believe that code is bug-prone and it might affect something one day when someone uses it outside of quicksort |
ladybird/AK/InsertionSort.h
Lines 14 to 23 in dd11d48
Is this code supposed to start at the beginning and end at the end? If so, should not be the inner loop be something like
Here's a test that indicated what I'm worried about
It fails.
So either I don't get the idea how it's supposed to work or it's just not working as expected....
The text was updated successfully, but these errors were encountered: