On Fri, 18 Jun 2021 at 18:44, Patrick Palka wrote:
>
> Ping; here's the same patch with the above comment corrected.
>
> -- >8 --
>
> Subject: [PATCH] libstdc++: Reduce ranges::minmax/minmax_element comparison
> complexity
>
> This rewrites ranges::minmax an
; + // comparison, for a total of 3*(N-1)/2 + 1 < 3*N/2
> > > > comparisons.
> > >
> > > Same comments on the comments as above.
> >
> > Fixed.
> >
> > >
> > > > + if (__comp_proj(*__prev, *__result.min)
t; + if (__comp_proj(*__prev, *__result.min))
> > > + __result.min = __prev;
> > > + if (!__comp_proj(*__first, *__result.max))
> > > + __result.max = __first;
> > > + }
> > > + else
> > > +
is an improvement though (except for
> being slightly fewer lines of code):
>
> auto __mm = minmax(__prev, __first, __comp,
>[](auto&& __it) -> auto&& { return *__it; });
>
> if (__comp_proj(*__mm.min, *__result.min))
> _
On 05/05/21 10:39 +0100, Jonathan Wakely wrote:
On 04/05/21 21:42 -0400, Patrick Palka via Libstdc++ wrote:
This rewrites ranges::minmax and ranges::minmax_element so that it
performs at most 3*N/2 many comparisons, as required by the standard.
In passing, this also fixes PR100387 by avoiding a
On 04/05/21 21:42 -0400, Patrick Palka via Libstdc++ wrote:
This rewrites ranges::minmax and ranges::minmax_element so that it
performs at most 3*N/2 many comparisons, as required by the standard.
In passing, this also fixes PR100387 by avoiding a premature std::move
in ranges::minmax and in std:
This rewrites ranges::minmax and ranges::minmax_element so that it
performs at most 3*N/2 many comparisons, as required by the standard.
In passing, this also fixes PR100387 by avoiding a premature std::move
in ranges::minmax and in std::shift_right.
Tested on x86_64-pc-linux-gnu, does this look O