Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r68874 - trunk/boost/random
From: steven_at_[hidden]
Date: 2011-02-14 17:44:11


Author: steven_watanabe
Date: 2011-02-14 17:44:10 EST (Mon, 14 Feb 2011)
New Revision: 68874
URL: http://svn.boost.org/trac/boost/changeset/68874

Log:
Apparently, neither gcc 4.5, nor msvc 10 can optimize away this loop.
Text files modified:
   trunk/boost/random/mersenne_twister.hpp | 9 ++-------
   1 files changed, 2 insertions(+), 7 deletions(-)

Modified: trunk/boost/random/mersenne_twister.hpp
==============================================================================
--- trunk/boost/random/mersenne_twister.hpp (original)
+++ trunk/boost/random/mersenne_twister.hpp 2011-02-14 17:44:10 EST (Mon, 14 Feb 2011)
@@ -22,6 +22,7 @@
 #include <stdexcept>
 #include <boost/config.hpp>
 #include <boost/cstdint.hpp>
+#include <boost/integer/integer_mask.hpp>
 #include <boost/random/detail/config.hpp>
 #include <boost/random/detail/ptr_helper.hpp>
 #include <boost/random/detail/seed.hpp>
@@ -182,13 +183,7 @@
     { return 0; }
     /** Returns the largest value that the generator can produce. */
     static result_type max BOOST_PREVENT_MACRO_SUBSTITUTION ()
- {
- // avoid "left shift count >= width of type" warning
- result_type res = 0;
- for(std::size_t j = 0; j < w; ++j)
- res |= (static_cast<result_type>(1) << j);
- return res;
- }
+ { return boost::low_bits_mask_t<w>::sig_bits; }
     
     /** Produces the next value of the generator. */
     result_type operator()();


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk