-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[libc++] [sort] Improve performance of std::sort #76616
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,8 +68,7 @@ void test_same() { | |
auto snapshot_custom_v = v; | ||
std::sort(v.begin(), v.end()); | ||
std::sort(snapshot_v.begin(), snapshot_v.end()); | ||
std::sort(snapshot_custom_v.begin(), snapshot_custom_v.end(), | ||
[](const EqualType&, const EqualType&) { return false; }); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why remove this test instead of just adding the new one? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The old test case passes There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But that means we start to strongly write our tests based on our current implementation. That's not a good idea in general. Having some duplicated test coverage can help during refactoring where different paths are taken. So I really like adding a test, I'm just less thrilled with the removal. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's worth noting that this is in It's also worth noting that this lambda doesn't meet the requirements of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
std::sort(snapshot_custom_v.begin(), snapshot_custom_v.end(), std::less<EqualType>()); | ||
bool all_equal = true; | ||
for (int i = 0; i < kSize; ++i) { | ||
if (v[i].value != snapshot_v[i].value || v[i].value != snapshot_custom_v[i].value) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are there already tests for sorting trivially_copyable types?