Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r56349 - trunk/boost/unordered/detail
From: daniel_james_at_[hidden]
Date: 2009-09-21 17:18:22


Author: danieljames
Date: 2009-09-21 17:18:21 EDT (Mon, 21 Sep 2009)
New Revision: 56349
URL: http://svn.boost.org/trac/boost/changeset/56349

Log:
Use std::max.
Text files modified:
   trunk/boost/unordered/detail/table.hpp | 11 +++++------
   1 files changed, 5 insertions(+), 6 deletions(-)

Modified: trunk/boost/unordered/detail/table.hpp
==============================================================================
--- trunk/boost/unordered/detail/table.hpp (original)
+++ trunk/boost/unordered/detail/table.hpp 2009-09-21 17:18:21 EDT (Mon, 21 Sep 2009)
@@ -417,10 +417,9 @@
     inline bool hash_table<H, P, A, G, K>::reserve_for_insert(std::size_t size)
     {
         if(size >= max_load_) {
- std::size_t s = this->size_;
- s = s + (s >> 1);
             std::size_t num_buckets
- = this->min_buckets_for_size(s > size ? s : size);
+ = this->min_buckets_for_size((std::max)(size,
+ this->size_ + (this->size_ >> 1)));
             if(num_buckets != this->bucket_count_) {
                 rehash_impl(num_buckets);
                 return true;
@@ -446,9 +445,9 @@
         else {
             // no throw:
             // TODO: Needlessly calling next_prime twice.
- std::size_t min_size = this->min_buckets_for_size(this->size_);
- min_buckets = next_prime(min_buckets);
- min_buckets = min_size > min_buckets ? min_size : min_buckets;
+ min_buckets = (std::max)(
+ next_prime(min_buckets),
+ this->min_buckets_for_size(this->size_));
             if(min_buckets != this->bucket_count_) rehash_impl(min_buckets);
         }
     }


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