public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug libstdc++/100223] New: Missing early return in std::partial_sort @ 2021-04-23 3:16 hewillk at gmail dot com 2021-04-23 8:23 ` [Bug libstdc++/100223] " redi at gcc dot gnu.org 2021-04-23 8:46 ` hewillk at gmail dot com 0 siblings, 2 replies; 3+ messages in thread From: hewillk at gmail dot com @ 2021-04-23 3:16 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100223 Bug ID: 100223 Summary: Missing early return in std::partial_sort Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: hewillk at gmail dot com Target Milestone: --- Hi, can we add an early return to std::partial_sort to avoid unnecessary O(n) operations when __first is equal to __middle, just like std::rotate does, and make the result more consistent with ranges::partial_sort? https://godbolt.org/z/Kb5x8zfeh ^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug libstdc++/100223] Missing early return in std::partial_sort 2021-04-23 3:16 [Bug libstdc++/100223] New: Missing early return in std::partial_sort hewillk at gmail dot com @ 2021-04-23 8:23 ` redi at gcc dot gnu.org 2021-04-23 8:46 ` hewillk at gmail dot com 1 sibling, 0 replies; 3+ messages in thread From: redi at gcc dot gnu.org @ 2021-04-23 8:23 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100223 --- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> --- Arguably, the caller can do this check if they think it can occur in their code. That way all calls to the algorithm don't pay for the check. But it's probably cheap enough to check anyway. ^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug libstdc++/100223] Missing early return in std::partial_sort 2021-04-23 3:16 [Bug libstdc++/100223] New: Missing early return in std::partial_sort hewillk at gmail dot com 2021-04-23 8:23 ` [Bug libstdc++/100223] " redi at gcc dot gnu.org @ 2021-04-23 8:46 ` hewillk at gmail dot com 1 sibling, 0 replies; 3+ messages in thread From: hewillk at gmail dot com @ 2021-04-23 8:46 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100223 --- Comment #2 from 康桓瑋 <hewillk at gmail dot com> --- (In reply to Jonathan Wakely from comment #1) > Arguably, the caller can do this check if they think it can occur in their > code. That way all calls to the algorithm don't pay for the check. > > But it's probably cheap enough to check anyway. Exactly, since the <algorithm> is full of such checks, I think there is nothing wrong with adding one for partial_sort. ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-04-23 8:46 UTC | newest] Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2021-04-23 3:16 [Bug libstdc++/100223] New: Missing early return in std::partial_sort hewillk at gmail dot com 2021-04-23 8:23 ` [Bug libstdc++/100223] " redi at gcc dot gnu.org 2021-04-23 8:46 ` hewillk at gmail dot com
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).