Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r80381 - trunk/boost/unordered/detail
From: dnljms_at_[hidden]
Date: 2012-09-03 16:02:55


Author: danieljames
Date: 2012-09-03 16:02:53 EDT (Mon, 03 Sep 2012)
New Revision: 80381
URL: http://svn.boost.org/trac/boost/changeset/80381

Log:
Unordered: Tweak node_construct functions.
Text files modified:
   trunk/boost/unordered/detail/buckets.hpp | 20 +++++++++-----------
   trunk/boost/unordered/detail/equivalent.hpp | 12 ++++--------
   trunk/boost/unordered/detail/table.hpp | 6 ++----
   trunk/boost/unordered/detail/unique.hpp | 20 ++++++--------------
   4 files changed, 21 insertions(+), 37 deletions(-)

Modified: trunk/boost/unordered/detail/buckets.hpp
==============================================================================
--- trunk/boost/unordered/detail/buckets.hpp (original)
+++ trunk/boost/unordered/detail/buckets.hpp 2012-09-03 16:02:53 EDT (Mon, 03 Sep 2012)
@@ -73,21 +73,21 @@
 
         ~node_constructor();
 
- void construct_node();
+ void construct();
 
         template <BOOST_UNORDERED_EMPLACE_TEMPLATE>
- void construct_value(BOOST_UNORDERED_EMPLACE_ARGS)
+ void construct_with_value(BOOST_UNORDERED_EMPLACE_ARGS)
         {
- BOOST_ASSERT(node_ && node_constructed_ && !value_constructed_);
+ construct();
             boost::unordered::detail::construct_value_impl(
                 alloc_, node_->value_ptr(), BOOST_UNORDERED_EMPLACE_FORWARD);
             value_constructed_ = true;
         }
 
         template <typename A0>
- void construct_value2(BOOST_FWD_REF(A0) a0)
+ void construct_with_value2(BOOST_FWD_REF(A0) a0)
         {
- BOOST_ASSERT(node_ && node_constructed_ && !value_constructed_);
+ construct();
             boost::unordered::detail::construct_value_impl(
                 alloc_, node_->value_ptr(),
                 BOOST_UNORDERED_EMPLACE_ARGS1(boost::forward<A0>(a0)));
@@ -132,7 +132,7 @@
     }
 
     template <typename Alloc>
- void node_constructor<Alloc>::construct_node()
+ void node_constructor<Alloc>::construct()
     {
         if(!node_) {
             node_constructed_ = false;
@@ -228,8 +228,7 @@
                 return p;
             }
             else {
- this->construct_node();
- this->construct_value2(v);
+ this->construct_with_value2(v);
                 return base::release();
             }
         }
@@ -244,8 +243,7 @@
                 return p;
             }
             else {
- this->construct_node();
- this->construct_value2(boost::move(v));
+ this->construct_with_value2(boost::move(v));
                 return base::release();
             }
         }
@@ -853,7 +851,7 @@
             else if (bucket::extra_node)
             {
                 node_constructor a(this->node_alloc());
- a.construct_node();
+ a.construct();
 
                 (constructor.get() +
                     static_cast<std::ptrdiff_t>(this->bucket_count_))->next_ =

Modified: trunk/boost/unordered/detail/equivalent.hpp
==============================================================================
--- trunk/boost/unordered/detail/equivalent.hpp (original)
+++ trunk/boost/unordered/detail/equivalent.hpp 2012-09-03 16:02:53 EDT (Mon, 03 Sep 2012)
@@ -487,8 +487,7 @@
         iterator emplace(BOOST_UNORDERED_EMPLACE_ARGS)
         {
             node_constructor a(this->node_alloc());
- a.construct_node();
- a.construct_value(BOOST_UNORDERED_EMPLACE_FORWARD);
+ a.construct_with_value(BOOST_UNORDERED_EMPLACE_FORWARD);
 
             return iterator(emplace_impl(a));
         }
@@ -507,8 +506,7 @@
             std::size_t distance = boost::unordered::detail::distance(i, j);
             if(distance == 1) {
                 node_constructor a(this->node_alloc());
- a.construct_node();
- a.construct_value2(*i);
+ a.construct_with_value2(*i);
                 emplace_impl(a);
             }
             else {
@@ -517,8 +515,7 @@
 
                 node_constructor a(this->node_alloc());
                 for (; i != j; ++i) {
- a.construct_node();
- a.construct_value2(*i);
+ a.construct_with_value2(*i);
                     emplace_impl_no_rehash(a);
                 }
             }
@@ -530,8 +527,7 @@
         {
             node_constructor a(this->node_alloc());
             for (; i != j; ++i) {
- a.construct_node();
- a.construct_value2(*i);
+ a.construct_with_value2(*i);
                 emplace_impl(a);
             }
         }

Modified: trunk/boost/unordered/detail/table.hpp
==============================================================================
--- trunk/boost/unordered/detail/table.hpp (original)
+++ trunk/boost/unordered/detail/table.hpp 2012-09-03 16:02:53 EDT (Mon, 03 Sep 2012)
@@ -67,8 +67,7 @@
         typename node_allocator_traits::pointer create(
                 typename node_allocator_traits::value_type::value_type const& v)
         {
- constructor.construct_node();
- constructor.construct_value2(v);
+ constructor.construct_with_value2(v);
             return constructor.release();
         }
     };
@@ -86,8 +85,7 @@
         typename node_allocator_traits::pointer create(
                 typename node_allocator_traits::value_type::value_type& v)
         {
- constructor.construct_node();
- constructor.construct_value2(boost::move(v));
+ constructor.construct_with_value2(boost::move(v));
             return constructor.release();
         }
     };

Modified: trunk/boost/unordered/detail/unique.hpp
==============================================================================
--- trunk/boost/unordered/detail/unique.hpp (original)
+++ trunk/boost/unordered/detail/unique.hpp 2012-09-03 16:02:53 EDT (Mon, 03 Sep 2012)
@@ -349,9 +349,7 @@
             // Create the node before rehashing in case it throws an
             // exception (need strong safety in such a case).
             node_constructor a(this->node_alloc());
- a.construct_node();
-
- a.construct_value(BOOST_UNORDERED_EMPLACE_ARGS3(
+ a.construct_with_value(BOOST_UNORDERED_EMPLACE_ARGS3(
                 boost::unordered::piecewise_construct,
                 boost::make_tuple(k),
                 boost::make_tuple()));
@@ -413,8 +411,7 @@
             // Create the node before rehashing in case it throws an
             // exception (need strong safety in such a case).
             node_constructor a(this->node_alloc());
- a.construct_node();
- a.construct_value(BOOST_UNORDERED_EMPLACE_FORWARD);
+ a.construct_with_value(BOOST_UNORDERED_EMPLACE_FORWARD);
     
             // reserve has basic exception safety if the hash function
             // throws, strong otherwise.
@@ -442,8 +439,7 @@
             // Don't have a key, so construct the node first in order
             // to be able to lookup the position.
             node_constructor a(this->node_alloc());
- a.construct_node();
- a.construct_value(BOOST_UNORDERED_EMPLACE_FORWARD);
+ a.construct_with_value(BOOST_UNORDERED_EMPLACE_FORWARD);
             return emplace_impl_with_node(a);
         }
 
@@ -490,8 +486,7 @@
             InputIt i, InputIt j)
         {
             std::size_t key_hash = this->hash(k);
- a.construct_node();
- a.construct_value2(*i);
+ a.construct_with_value2(*i);
             this->reserve_for_insert(this->size_ +
                 boost::unordered::detail::insert_size(i, j));
             this->add_node(a, key_hash);
@@ -506,9 +501,7 @@
             iterator pos = this->find_node(key_hash, k);
     
             if (!pos.node_) {
- a.construct_node();
- a.construct_value2(*i);
-
+ a.construct_with_value2(*i);
                 if(this->size_ + 1 > this->max_load_)
                     this->reserve_for_insert(this->size_ +
                         boost::unordered::detail::insert_size(i, j));
@@ -524,8 +517,7 @@
             node_constructor a(this->node_alloc());
 
             do {
- a.construct_node();
- a.construct_value2(*i);
+ a.construct_with_value2(*i);
                 emplace_impl_with_node(a);
             } while(++i != j);
         }


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