From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13153 invoked by alias); 1 Nov 2012 19:34:39 -0000 Received: (qmail 6732 invoked by uid 48); 1 Nov 2012 19:34:24 -0000 From: "chri.snell at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/55169] New: std::discrete_distribution::operator(generator&) makes unnecessary copy of parameter vector Date: Thu, 01 Nov 2012 19:34:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: chri.snell at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2012-11/txt/msg00062.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55169 Bug #: 55169 Summary: std::discrete_distribution::operator(generator&) makes unnecessary copy of parameter vector Classification: Unclassified Product: gcc Version: 4.7.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ AssignedTo: unassigned@gcc.gnu.org ReportedBy: chri.snell@gmail.com Created attachment 28592 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=28592 demonstration of slow std::discrete_distribution in GCC std::discrete_distribution::operator()(generator&) is significantly slower than directly calling operator()(generator&, const param_type&), which it delegates to. This is because, on random.h:4805, this->param() returns a copy rather than a const reference. The attached file is a simple test demonstrating this inefficient behaviour.