Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r52346 - in branches/release: . boost/unordered/detail
From: daniel_james_at_[hidden]
Date: 2009-04-12 06:25:39


Author: danieljames
Date: 2009-04-12 06:25:38 EDT (Sun, 12 Apr 2009)
New Revision: 52346
URL: http://svn.boost.org/trac/boost/changeset/52346

Log:
Merged revisions 52224 via svnmerge from
https://svn.boost.org/svn/boost/trunk

........
  r52224 | danieljames | 2009-04-06 23:51:36 +0100 (Mon, 06 Apr 2009) | 1 line
  
  Avoid an unnecessary copy in 'operator[]'
........

Properties modified:
   branches/release/ (props changed)
Text files modified:
   branches/release/boost/unordered/detail/hash_table_impl.hpp | 18 +++++++++++++++++-
   1 files changed, 17 insertions(+), 1 deletions(-)

Modified: branches/release/boost/unordered/detail/hash_table_impl.hpp
==============================================================================
--- branches/release/boost/unordered/detail/hash_table_impl.hpp (original)
+++ branches/release/boost/unordered/detail/hash_table_impl.hpp 2009-04-12 06:25:38 EDT (Sun, 12 Apr 2009)
@@ -215,6 +215,22 @@
                 }
 #endif
 
+ template <typename K, typename M>
+ void construct_pair(K const& k, M*)
+ {
+ BOOST_ASSERT(!node_);
+ node_constructed_ = false;
+ value_constructed_ = false;
+
+ node_ = allocators_.node_alloc_.allocate(1);
+
+ allocators_.node_alloc_.construct(node_, node());
+ node_constructed_ = true;
+
+ new(node_->address()) value_type(k, M());
+ value_constructed_ = true;
+ }
+
                 node_ptr get() const
                 {
                     BOOST_ASSERT(node_);
@@ -1757,7 +1773,7 @@
                     // Create the node before rehashing in case it throws an
                     // exception (need strong safety in such a case).
                     node_constructor a(data_.allocators_);
- a.construct(value_type(k, mapped_type()));
+ a.construct_pair(k, (mapped_type*) 0);
 
                     // reserve has basic exception safety if the hash function
                     // throws, strong otherwise.


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