This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: 4-15% speed-up in std::sort special case - is it worth the effort?


On Wed, Aug 25, 2010 at 2:44 AM, Jaroslav Hajek <highegg@gmail.com> wrote:
> Hi all,
>
> I've been experimenting with sorting recently and I have noticed a
> possibility to slightly optimize the sorting of std::pair values using
> the default < operator. This is, I believe, a common usage case to
> retrieve sorting indices (better locality of reference than sorting
> via pointers). At least I usually do it that way :)
>
> The idea is simple: we know how the < operator for std::pairs looks
> like; basically it's
> x.first < y.first || (! (y.first < x.first) && x.second < y.second)
>

std::pair can be specialized (along with user defined comparators.)
How are you handling that?


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]