This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: 4-15% speed-up in std::sort special case - is it worth the effort?
- From: Gabriel Dos Reis <gdr at integrable-solutions dot net>
- To: Jaroslav Hajek <highegg at gmail dot com>
- Cc: libstdc++ at gcc dot gnu dot org, gcc at gcc dot gnu dot org
- Date: Tue, 19 Oct 2010 12:31:17 -0500
- Subject: Re: 4-15% speed-up in std::sort special case - is it worth the effort?
- References: <AANLkTi=vqpLp38Qdy0HBO7rS3SLN5TYTzcx+cfK9R_EK@mail.gmail.com>
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?