* Improved vector's insertion performance.

*  Changed again experimental multiallocation interface for better performance (still experimental).
*  Added no exception support for those willing to disable exceptions in their compilers.
*  Fixed GCC -Wshadow warnings.
*  Replaced deprecated BOOST_NO_XXXX with newer BOOST_NO_CXX11_XXX macros.


[SVN r81518]
This commit is contained in:
Ion Gaztañaga committed 2012-11-24 21:08:18 +00:00
1 parent a75d72d03c
commit bc5c91bb79
28 files changed
+2449 -1892

No files matched your search

+36 -36
View File
@@ -25,7 +25,7 @@
#include <utility>
#include <boost/type_traits/has_trivial_destructor.hpp>
#include <boost/move/move.hpp>
#include <boost/move/utility.hpp>
#include <boost/container/detail/utilities.hpp>
#include <boost/container/detail/pair.hpp>
@@ -48,7 +48,7 @@ class flat_tree_value_compare
typedef Value first_argument_type;
typedef Value second_argument_type;
typedef bool return_type;
public:
public:
flat_tree_value_compare()
: Compare()
{}
@@ -65,7 +65,7 @@ class flat_tree_value_compare
const Compare &get_comp() const
{ return *this; }
Compare &get_comp()
{ return *this; }
};
@@ -238,7 +238,7 @@ class flat_tree
flat_tree& operator=(BOOST_RV_REF(flat_tree) mx)
{ m_data = boost::move(mx.m_data); return *this; }
public:
public:
// accessors:
Compare key_comp() const
{ return this->m_data.get_comp(); }
@@ -441,17 +441,17 @@ class flat_tree
//Prereserve all memory so that iterators are not invalidated
this->reserve(this->size()+len);
const const_iterator beg(this->cbegin());
const_iterator pos(beg);
const const_iterator b(this->cbegin());
const_iterator pos(b);
//Loop in burst sizes
while(len){
const size_type burst = len < BurstSize ? len : BurstSize;
const const_iterator cend_(this->cend());
const const_iterator ce(this->cend());
len -= burst;
for(size_type i = 0; i != burst; ++i){
//Get the insertion position for each key
pos = const_cast<const flat_tree&>(*this).priv_upper_bound(pos, cend_, KeyOfValue()(*first));
positions[i] = static_cast<size_type>(pos - beg);
pos = const_cast<const flat_tree&>(*this).priv_upper_bound(pos, ce, KeyOfValue()(*first));
positions[i] = static_cast<size_type>(pos - b);
++first;
}
//Insert all in a single step in the precalculated positions
@@ -489,22 +489,22 @@ class flat_tree
//Prereserve all memory so that iterators are not invalidated
this->reserve(this->size()+len);
const const_iterator beg(this->cbegin());
const_iterator pos(beg);
const const_iterator b(this->cbegin());
const_iterator pos(b);
const value_compare &value_comp = this->m_data;
skips[0u] = 0u;
//Loop in burst sizes
while(len){
const size_type burst = len < BurstSize ? len : BurstSize;
size_type unique_burst = 0u;
const const_iterator cend_(this->cend());
const const_iterator ce(this->cend());
while(unique_burst < burst && len > 0){
//Get the insertion position for each key
const value_type & val = *first++;
--len;
pos = const_cast<const flat_tree&>(*this).priv_lower_bound(pos, cend_, KeyOfValue()(val));
pos = const_cast<const flat_tree&>(*this).priv_lower_bound(pos, ce, KeyOfValue()(val));
//Check if already present
if(pos != cend_ && !value_comp(val, *pos)){
if(pos != ce && !value_comp(val, *pos)){
if(unique_burst > 0){
++skips[unique_burst-1];
}
@@ -512,7 +512,7 @@ class flat_tree
}
//If not present, calculate position
positions[unique_burst] = static_cast<size_type>(pos - beg);
positions[unique_burst] = static_cast<size_type>(pos - b);
skips[unique_burst++] = 0u;
}
if(unique_burst){
@@ -692,22 +692,22 @@ class flat_tree
// set operations:
iterator find(const key_type& k)
{
const Compare &key_comp_ = this->m_data.get_comp();
const Compare &key_cmp = this->m_data.get_comp();
iterator i = this->lower_bound(k);
if (i != this->end() && key_comp_(k, KeyOfValue()(*i))){
i = this->end();
if (i != this->end() && key_cmp(k, KeyOfValue()(*i))){
i = this->end();
}
return i;
}
const_iterator find(const key_type& k) const
{
const Compare &key_comp_ = this->m_data.get_comp();
const Compare &key_cmp = this->m_data.get_comp();
const_iterator i = this->lower_bound(k);
if (i != this->end() && key_comp_(k, KeyOfValue()(*i))){
i = this->end();
if (i != this->end() && key_cmp(k, KeyOfValue()(*i))){
i = this->end();
}
return i;
}
@@ -737,11 +737,11 @@ class flat_tree
std::pair<const_iterator, const_iterator> equal_range(const key_type& k) const
{ return this->priv_equal_range(this->begin(), this->end(), k); }
size_type capacity() const
size_type capacity() const
{ return this->m_data.m_vect.capacity(); }
void reserve(size_type count_)
{ this->m_data.m_vect.reserve(count_); }
void reserve(size_type cnt)
{ this->m_data.m_vect.reserve(cnt); }
private:
struct insert_commit_data
@@ -780,13 +780,13 @@ class flat_tree
}
std::pair<iterator,bool> priv_insert_unique_prepare
(const_iterator beg, const_iterator end_, const value_type& val, insert_commit_data &commit_data)
(const_iterator b, const_iterator e, const value_type& val, insert_commit_data &commit_data)
{
const value_compare &value_comp = this->m_data;
commit_data.position = this->priv_lower_bound(beg, end_, KeyOfValue()(val));
commit_data.position = this->priv_lower_bound(b, e, KeyOfValue()(val));
return std::pair<iterator,bool>
( *reinterpret_cast<iterator*>(&commit_data.position)
, commit_data.position == end_ || value_comp(val, *commit_data.position));
, commit_data.position == e || value_comp(val, *commit_data.position));
}
std::pair<iterator,bool> priv_insert_unique_prepare
@@ -854,7 +854,7 @@ class flat_tree
RanIt priv_lower_bound(RanIt first, RanIt last,
const key_type & key) const
{
const Compare &key_comp_ = this->m_data.get_comp();
const Compare &key_cmp = this->m_data.get_comp();
KeyOfValue key_extract;
difference_type len = last - first, half;
RanIt middle;
@@ -864,7 +864,7 @@ class flat_tree
middle = first;
middle += half;
if (key_comp_(key_extract(*middle), key)) {
if (key_cmp(key_extract(*middle), key)) {
++middle;
first = middle;
len = len - half - 1;
@@ -879,7 +879,7 @@ class flat_tree
RanIt priv_upper_bound(RanIt first, RanIt last,
const key_type & key) const
{
const Compare &key_comp_ = this->m_data.get_comp();
const Compare &key_cmp = this->m_data.get_comp();
KeyOfValue key_extract;
difference_type len = last - first, half;
RanIt middle;
@@ -889,12 +889,12 @@ class flat_tree
middle = first;
middle += half;
if (key_comp_(key, key_extract(*middle))) {
if (key_cmp(key, key_extract(*middle))) {
len = half;
}
else{
first = ++middle;
len = len - half - 1;
len = len - half - 1;
}
}
return first;
@@ -904,7 +904,7 @@ class flat_tree
std::pair<RanIt, RanIt>
priv_equal_range(RanIt first, RanIt last, const key_type& key) const
{
const Compare &key_comp_ = this->m_data.get_comp();
const Compare &key_cmp = this->m_data.get_comp();
KeyOfValue key_extract;
difference_type len = last - first, half;
RanIt middle, left, right;
@@ -914,12 +914,12 @@ class flat_tree
middle = first;
middle += half;
if (key_comp_(key_extract(*middle), key)){
if (key_cmp(key_extract(*middle), key)){
first = middle;
++first;
len = len - half - 1;
}
else if (key_comp_(key, key_extract(*middle))){
else if (key_cmp(key, key_extract(*middle))){
len = half;
}
else {
@@ -1033,7 +1033,7 @@ template <class K, class V, class KOV,
class C, class A>
struct has_trivial_destructor_after_move<boost::container::container_detail::flat_tree<K, V, KOV, C, A> >
{
static const bool value = has_trivial_destructor<A>::value && has_trivial_destructor<C>::value;
static const bool value = has_trivial_destructor_after_move<A>::value && has_trivial_destructor_after_move<C>::value;
};
*/
} //namespace boost {