[Bug libstdc++/55169] New: std::discrete_distribution::operator(generator&) makes unnecessary copy of parameter vector

2012-11-01 Thread chri.snell at gmail dot com


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: unassig...@gcc.gnu.org

ReportedBy: chri.sn...@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.


[Bug libstdc++/55169] std::discrete_distribution::operator(generator&) makes unnecessary copy of parameter vector

2012-11-01 Thread chri.snell at gmail dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55169



--- Comment #2 from Chris Nell  2012-11-01 
19:48:43 UTC ---

After a bit more poking, it appears that param() returns a copy (not a const

reference) for all distributions, not just discrete_distribution.  As such, it

might we worth looking into whether other implementations of

operator(generator&) suffer from the same bug.