[patch, libstdc++] Optimize selection sampling by using generator to get two values at once

2016-10-19 Thread Eelis van der Weegen
This is the same optimization as was recently applied to std::shuffle. It reduces the runtime of the following program by 20% on my machine: int main() { std::vector a(1), b(1000); std::mt19937 gen; uint64_t c = 0;

Re: [patch, libstdc++] std::shuffle: Generate two swap positions at a time if possible

2016-09-02 Thread Eelis van der Weegen
On 2016-08-31 14:45, Jonathan Wakely wrote: Is this significantly faster than just using uniform_int_distribution<_IntType>{0, __bound - 1}(__g) so we don't need to duplicate the logic? (And people maintaining the code won't reconvince themselves it's correct every time they look at it :-) [..]

Re: [patch, libstdc++] std::shuffle: Generate two swap positions at a time if possible

2016-09-01 Thread Eelis van der Weegen
On 2016-09-01 17:14, Jonathan Wakely wrote: On 31/08/16 13:45 +0100, Jonathan Wakely wrote: On 03/05/16 16:42 +0200, Eelis van der Weegen wrote: Ah, thanks, I forgot to re-attach when I sent to include the libstdc++ list. On 2016-05-03 14:38, Jonathan Wakely wrote: ENOPATCH On 1 May 2016 at

Re: [patch, libstdc++] std::shuffle: Generate two swap positions at a time if possible

2016-05-03 Thread Eelis van der Weegen
Ah, thanks, I forgot to re-attach when I sent to include the libstdc++ list. On 2016-05-03 14:38, Jonathan Wakely wrote: ENOPATCH On 1 May 2016 at 15:21, Eelis wrote: Sorry, forgot to include the libstdc++ list. On 2016-05-01 16:18, Eelis wrote: Hi, The attached patch optimizes std::shuff

Re: [patch, libstdc++] In debug mode, diagnose empty initializer_list in min/max/minmax

2016-02-25 Thread Eelis van der Weegen
On 2016-02-23 23:39, Jonathan Wakely wrote: On 23/02/16 22:03 +0100, Eelis wrote: The std::min, std::max, and std::minmax overloads that take a std::initializer_list all require that the list is not empty. The attached patch adds debug mode checks for this. Nice, thanks for the patch. Hi J