Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r80743 - in trunk/boost/container: . detail
From: igaztanaga_at_[hidden]
Date: 2012-09-28 17:07:03


Author: igaztanaga
Date: 2012-09-28 17:07:02 EDT (Fri, 28 Sep 2012)
New Revision: 80743
URL: http://svn.boost.org/trac/boost/changeset/80743

Log:
Bug #7439
Text files modified:
   trunk/boost/container/detail/flat_tree.hpp | 21 ++++++++++++---------
   trunk/boost/container/vector.hpp | 17 ++++++++---------
   2 files changed, 20 insertions(+), 18 deletions(-)

Modified: trunk/boost/container/detail/flat_tree.hpp
==============================================================================
--- trunk/boost/container/detail/flat_tree.hpp (original)
+++ trunk/boost/container/detail/flat_tree.hpp 2012-09-28 17:07:02 EDT (Fri, 28 Sep 2012)
@@ -491,9 +491,9 @@
       const const_iterator beg(this->cbegin());
       const_iterator pos(beg);
       const value_compare &value_comp = this->m_data;
+ skips[0u] = 0u;
       //Loop in burst sizes
       while(len){
- skips[0u] = 0u;
          const size_type burst = len < BurstSize ? len : BurstSize;
          size_type unique_burst = 0u;
          const const_iterator cend(this->cend());
@@ -503,20 +503,23 @@
             --len;
             pos = const_cast<const flat_tree&>(*this).priv_lower_bound(pos, cend, KeyOfValue()(val));
             //Check if already present
- if(pos != cend && !value_comp(*pos, val)){
- ++skips[unique_burst];
+ if(pos != cend && !value_comp(val, *pos)){
+ if(unique_burst > 0){
+ ++skips[unique_burst-1];
+ }
                continue;
             }
 
             //If not present, calculate position
             positions[unique_burst] = static_cast<size_type>(pos - beg);
- if(++unique_burst < burst)
- skips[unique_burst] = 0u;
+ skips[unique_burst++] = 0u;
+ }
+ if(unique_burst){
+ //Insert all in a single step in the precalculated positions
+ this->m_data.m_vect.insert_ordered_at(unique_burst, positions + unique_burst, skips + unique_burst, first);
+ //Next search position updated
+ pos += unique_burst;
          }
- //Insert all in a single step in the precalculated positions
- this->m_data.m_vect.insert_ordered_at(unique_burst, positions + unique_burst, skips + unique_burst, first);
- //Next search position updated
- pos += unique_burst;
       }
    }
 

Modified: trunk/boost/container/vector.hpp
==============================================================================
--- trunk/boost/container/vector.hpp (original)
+++ trunk/boost/container/vector.hpp 2012-09-28 17:07:02 EDT (Fri, 28 Sep 2012)
@@ -683,6 +683,7 @@
    allocator_type get_allocator() const BOOST_CONTAINER_NOEXCEPT
    { return this->alloc(); }
 
+
    //! <b>Effects</b>: Returns a reference to the internal allocator.
    //!
    //! <b>Throws</b>: Nothing
@@ -690,7 +691,7 @@
    //! <b>Complexity</b>: Constant.
    //!
    //! <b>Note</b>: Non-standard extension.
- const stored_allocator_type &get_stored_allocator() const BOOST_CONTAINER_NOEXCEPT
+ stored_allocator_type &get_stored_allocator() BOOST_CONTAINER_NOEXCEPT
    { return this->alloc(); }
 
    //! <b>Effects</b>: Returns a reference to the internal allocator.
@@ -700,7 +701,7 @@
    //! <b>Complexity</b>: Constant.
    //!
    //! <b>Note</b>: Non-standard extension.
- stored_allocator_type &get_stored_allocator() BOOST_CONTAINER_NOEXCEPT
+ const stored_allocator_type &get_stored_allocator() const BOOST_CONTAINER_NOEXCEPT
    { return this->alloc(); }
 
    //////////////////////////////////////////////
@@ -957,7 +958,7 @@
    //!
    //! <b>Complexity</b>: Linear to size().
    void shrink_to_fit()
- { priv_shrink_to_fit(alloc_version()); }
+ { this->priv_shrink_to_fit(alloc_version()); }
 
    //////////////////////////////////////////////
    //
@@ -1535,6 +1536,10 @@
       //Loop for each insertion backwards, first moving the elements after the insertion point,
       //then inserting the element.
       while(insertions_left){
+ if(do_skip){
+ size_type n = *(--last_skip_it);
+ std::advance(last_value_it, -difference_type(n));
+ }
          const size_type pos = static_cast<size_type>(*(--last_position_it));
          BOOST_ASSERT(pos <= old_size_pos);
          //If needed shift the range after the insertion point and the previous insertion point.
@@ -1569,12 +1574,6 @@
             //Insert the new value in the already constructed range
             begin_ptr[pos + insertions_left - 1] = *(--last_value_it);
          }
- if(do_skip){
- size_type n = *(--last_skip_it);
- while(n--){
- --last_value_it;
- }
- }
          --insertions_left;
          hole_size = new_hole_size;
          next_pos = pos;


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