If __first == __middle, then partial_sort is a no-op; don't bother to iterate all the way from __middle to __end.
Details
Details
- Reviewers
ldionne • hewillk Mordante - Group Reviewers
Restricted Project - Commits
- rGf6fb7bf636e3: [libc++] Add an early return for __partial_sort of an empty range.
Diff Detail
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
libcxx/include/__algorithm/partial_sort.h | ||
---|---|---|
33–34 | Nit, but this patch seems small enough to change that. |
Comment Actions
Any appetite for adding a test that counts the numbers of comparisons to bind this behavior? Otherwise, LGTM!
Comment Actions
LGTM, but I agree it would be good to add a test to avoid regressing that if we change our partial_sort implementation (which we might very well do at some point, since there is some work happening on std::sort).
Comment Actions
BTW, that was not binding -- as discussed offline, I think it is reasonable to try to tackle complexity tests separately from this patch, and more generally for all the algorithms.
Nit, but this patch seems small enough to change that.