Compilation times improvements

[SVN r37749]
This commit is contained in:
Ion Gaztañaga
2007-05-23 16:07:03 +00:00
parent 3c84ecf0e1
commit 4b48e69a82
9 changed files with 178 additions and 29 deletions

View File

@@ -15,10 +15,7 @@
#define BOOST_INTRUSIVE_CIRCULAR_LIST_ALGORITHMS_HPP
#include <boost/intrusive/detail/config_begin.hpp>
#include <iterator>
#include <boost/assert.hpp>
#include <boost/intrusive/intrusive_fwd.hpp>
#include <boost/intrusive/detail/pointer_to_other.hpp>
#include <cstddef>
namespace boost {
@@ -175,8 +172,10 @@ class circular_list_algorithms
//! <b>Complexity</b>: Constant
//!
//! <b>Throws</b>: Nothing.
/*
static void swap_nodes(node_ptr this_node, node_ptr other_node)
{
if (other_node == this_node)
return;
bool empty1 = unique(this_node);
@@ -209,7 +208,8 @@ class circular_list_algorithms
NodeTraits::set_previous(next_this, other_node);
}
}
/*
*/
//Watanabe version
private:
static void swap_prev(node_ptr this_node, node_ptr other_node)
@@ -238,7 +238,7 @@ class circular_list_algorithms
swap_next(this_node, other_node);
swap_prev(this_node, other_node);
}
*/
//! <b>Requires</b>: b and e must be nodes of the same circular list or an empty range.
//! and p must be a node of a different circular list or may not be an iterator in
// [b, e).

View File

@@ -15,10 +15,7 @@
#define BOOST_INTRUSIVE_CIRCULAR_SLIST_ALGORITHMS_HPP
#include <boost/intrusive/detail/config_begin.hpp>
#include <iterator>
#include <boost/assert.hpp>
#include <boost/intrusive/intrusive_fwd.hpp>
#include <boost/intrusive/detail/pointer_to_other.hpp>
#include <cstddef>
namespace boost {
@@ -202,7 +199,8 @@ class circular_slist_algorithms
//! <b>Throws</b>: Nothing.
static void link_after(node_ptr prev_node, node_ptr this_node)
{
NodeTraits::set_next(this_node, NodeTraits::get_next(prev_node));
node_ptr this_nxt = NodeTraits::get_next(prev_node);
NodeTraits::set_next(this_node, this_nxt);
NodeTraits::set_next(prev_node, this_node);
}

View File

@@ -18,9 +18,13 @@
#include <boost/assert.hpp>
#include <boost/intrusive/detail/pointer_to_other.hpp>
#include <boost/intrusive/circular_list_algorithms.hpp>
#ifdef BOOST_INTRUSIVE_USE_ITERATOR_FACADE
#include <boost/iterator/iterator_facade.hpp>
#endif
#ifdef BOOST_INTRUSIVE_USE_ITERATOR_ENABLE_IF_CONVERTIBLE
#include <boost/utility/enable_if.hpp>
#include <boost/type_traits/is_convertible.hpp>
#endif
#include <cstddef>
namespace boost {
@@ -102,6 +106,8 @@ struct bucket_info_impl
size_type buckets_len_;
};
#ifdef BOOST_INTRUSIVE_USE_ITERATOR_FACADE
template<class Value, class SlistImpl>
class hashtable_iterator
: public boost::iterator_facade
@@ -138,6 +144,8 @@ class hashtable_iterator
: local_it_ (ptr), bucket_info_ (bucket_info)
{}
#ifdef BOOST_INTRUSIVE_USE_ITERATOR_ENABLE_IF_CONVERTIBLE
template <class OtherValue>
hashtable_iterator(hashtable_iterator<OtherValue, SlistImpl> const& other
,typename boost::enable_if<
@@ -147,6 +155,15 @@ class hashtable_iterator
)
: local_it_(other.local_it_), bucket_info_(other.bucket_info_)
{}
#else
template <class OtherValue>
hashtable_iterator(hashtable_iterator<OtherValue, SlistImpl> const& other,
typename enable_if<
is_convertible<OtherValue*,T*>
>::type* = 0)
: local_it_(other.local_it_), bucket_info_(other.bucket_info_)
{}
#endif
const local_iterator &local() const
{ return local_it_; }
@@ -195,6 +212,123 @@ class hashtable_iterator
const_bucket_info_ptr bucket_info_;
};
#else
template<class T, class SlistImpl>
class hashtable_iterator
: public std::iterator<std::forward_iterator_tag, T>
{
typedef typename SlistImpl::iterator local_iterator;
typedef typename SlistImpl::const_iterator const_local_iterator;
typedef typename SlistImpl::value_traits::node_ptr node_ptr;
typedef typename SlistImpl::value_traits::const_node_ptr const_node_ptr;
typedef bucket_type_impl<SlistImpl> bucket_type;
typedef typename boost::pointer_to_other
< typename SlistImpl::pointer, bucket_type>::type bucket_ptr;
typedef typename boost::pointer_to_other
< typename SlistImpl::pointer, const bucket_type>::type const_bucket_ptr;
typedef detail::bucket_info_impl<SlistImpl> bucket_info_t;
typedef typename boost::pointer_to_other
<bucket_ptr, bucket_info_t>::type bucket_info_ptr;
typedef typename boost::pointer_to_other
<bucket_ptr, const bucket_info_t>::type const_bucket_info_ptr;
typedef typename SlistImpl::size_type size_type;
struct enabler {};
public:
typedef T & reference;
typedef T * pointer;
hashtable_iterator ()
{}
explicit hashtable_iterator(local_iterator ptr, const_bucket_info_ptr bucket_info)
: local_it_ (ptr), bucket_info_ (bucket_info)
{}
#ifdef BOOST_INTRUSIVE_USE_ITERATOR_ENABLE_IF_CONVERTIBLE
template <class OtherValue>
hashtable_iterator(hashtable_iterator<OtherValue, SlistImpl> const& other
,typename boost::enable_if<
boost::is_convertible<OtherValue*,T*>
, enabler
>::type = enabler()
)
: local_it_(other.local_it_), bucket_info_(other.bucket_info_)
{}
#else
template <class OtherValue>
hashtable_iterator(hashtable_iterator<OtherValue, SlistImpl> const& other,
typename enable_if<
is_convertible<OtherValue*,T*>
>::type* = 0)
: local_it_(other.local_it_), bucket_info_(other.bucket_info_)
{}
#endif
const local_iterator &local() const
{ return local_it_; }
const_node_ptr pointed_node() const
{ return local_it_.pointed_node(); }
const const_bucket_info_ptr &bucket_info() const
{ return bucket_info_; }
public:
hashtable_iterator& operator++()
{ increment(); return *this; }
hashtable_iterator operator++(int)
{
hashtable_iterator result (*this);
increment();
return result;
}
friend bool operator== (const hashtable_iterator& i, const hashtable_iterator& i2)
{ return i.pointed_node() == i2.pointed_node(); }
friend bool operator!= (const hashtable_iterator& i, const hashtable_iterator& i2)
{ return !(i == i2); }
T& operator*() const
{ return *local_it_; }
pointer operator->() const
{ return &(*local_it_); }
private:
void increment()
{
size_type buckets_len = bucket_info_->buckets_len_;
const_bucket_ptr buckets = bucket_info_->buckets_;
const_local_iterator first = bucket_type::bucket_to_slist(buckets[0]).cend();
const_local_iterator last = bucket_type::bucket_to_slist(buckets[buckets_len]).cend();
++local_it_;
if(first.pointed_node() <= local_it_.pointed_node() &&
local_it_.pointed_node() <= last.pointed_node()){
size_type n_bucket = (size_type)
bucket_type::get_bucket_num(local_it_, buckets[0], buckets[buckets_len]);
do{
if (++n_bucket == buckets_len){
local_it_ = bucket_info_->buckets_->end();
break;
}
local_it_ = bucket_type::bucket_to_slist(bucket_info_->buckets_[n_bucket]).begin();
}
while (local_it_ == bucket_type::bucket_to_slist(bucket_info_->buckets_[n_bucket]).end());
}
}
local_iterator local_it_;
const_bucket_info_ptr bucket_info_;
};
#endif
} //namespace detail {
} //namespace intrusive {
} //namespace boost {

View File

@@ -26,7 +26,6 @@
#include <boost/utility/enable_if.hpp>
#include <boost/type_traits/is_convertible.hpp>
#endif
#include <cstddef>
namespace boost {
namespace intrusive {
@@ -94,6 +93,7 @@ class list_iterator
: node_ (node)
{}
#ifdef BOOST_INTRUSIVE_USE_ITERATOR_ENABLE_IF_CONVERTIBLE
template <class OtherValue>
list_iterator(list_iterator<OtherValue, ValueTraits> const& other
,typename boost::enable_if<
@@ -103,6 +103,15 @@ class list_iterator
)
: node_(other.pointed_node())
{}
#else
template <class OtherValue>
list_iterator(list_iterator<OtherValue, ValueTraits> const& other,
typename enable_if<
is_convertible<OtherValue*,T*>
>::type* = 0)
: node_(other.pointed_node())
{}
#endif
const node_ptr &pointed_node() const
{ return node_; }

View File

@@ -21,11 +21,14 @@ namespace detail {
template<class Parent, class Member>
std::size_t offset_from_pointer_to_member(const Member Parent::* ptr_to_member)
{
//This works with gcc and msvc
//The implementation of a pointer to member is compiler dependent.
#if defined(BOOST_MSVC) || defined(__GNUC__) || defined(BOOST_INTEL)
#if defined(BOOST_MSVC) || defined(__GNUC__) || \
defined(BOOST_INTEL) || defined(__HP_aCC) || \
defined(__EDG_VERSION__)
//This works with gcc, msvc, edg, ac++
return *(const std::size_t*)(const void*)&ptr_to_member;
#else //CW 9.4
#else
//This is the traditional C-front approach: CW 9.4, dmc
return *(const std::size_t*)(const void*)&ptr_to_member - 1;
#endif
}

View File

@@ -16,12 +16,8 @@
#include <boost/intrusive/detail/config_begin.hpp>
#include <iterator>
#include <boost/assert.hpp>
#include <boost/intrusive/detail/pointer_to_other.hpp>
#include <boost/intrusive/rbtree_algorithms.hpp>
#include <boost/type_traits/alignment_of.hpp>
#include <cstddef>
#include <boost/detail/no_exceptions_support.hpp>
#ifdef BOOST_INTRUSIVE_USE_ITERATOR_FACADE
#include <boost/iterator/iterator_facade.hpp>
#endif
@@ -219,6 +215,7 @@ class rbtree_iterator
: node_ (node)
{}
#ifdef BOOST_INTRUSIVE_USE_ITERATOR_ENABLE_IF_CONVERTIBLE
template <class OtherValue>
rbtree_iterator(rbtree_iterator<OtherValue, ValueTraits> const& other
,typename boost::enable_if<
@@ -228,6 +225,15 @@ class rbtree_iterator
)
: node_(other.pointed_node())
{}
#else
template <class OtherValue>
rbtree_iterator(rbtree_iterator<OtherValue, ValueTraits> const& other,
typename enable_if<
is_convertible<OtherValue*,T*>
>::type* = 0)
: node_(other.pointed_node())
{}
#endif
const node_ptr &pointed_node() const
{ return node_; }

View File

@@ -26,7 +26,6 @@
#include <boost/utility/enable_if.hpp>
#include <boost/type_traits/is_convertible.hpp>
#endif
#include <cstddef>
namespace boost {
namespace intrusive {
@@ -154,21 +153,26 @@ class slist_iterator
explicit slist_iterator(node_ptr node)
: node_ (node)
{}
/*
#ifdef BOOST_INTRUSIVE_USE_ITERATOR_ENABLE_IF_CONVERTIBLE
template <class OtherValue>
slist_iterator(slist_iterator<OtherValue, ValueTraits> const& other
,typename boost::enable_if<
,typename boost::enable_if<
boost::is_convertible<OtherValue*,T*>
, enabler
>::type = enabler()
)
)
: node_(other.pointed_node())
{}
*/
#else
template <class OtherValue>
slist_iterator(slist_iterator<OtherValue, ValueTraits> const& other)
slist_iterator(slist_iterator<OtherValue, ValueTraits> const& other,
typename enable_if<
is_convertible<OtherValue*,T*>
>::type* = 0)
: node_(other.pointed_node())
{}
#endif
const node_ptr &pointed_node() const
{ return node_; }

View File

@@ -15,7 +15,6 @@
#include <boost/intrusive/detail/config_begin.hpp>
//std C++
#include <functional>
#include <iterator>
#include <utility>
#include <algorithm>
//boost
@@ -33,7 +32,6 @@
#include <boost/intrusive/unordered_set_hook.hpp>
#include <boost/intrusive/slist.hpp>
#include <cstddef>
#include <iterator>
namespace boost {
namespace intrusive {

View File

@@ -40,11 +40,8 @@
#define BOOST_INTRUSIVE_RBTREE_ALGORITHMS_HPP
#include <boost/intrusive/detail/config_begin.hpp>
#include <iterator>
#include <boost/assert.hpp>
#include <boost/intrusive/intrusive_fwd.hpp>
#include <boost/intrusive/detail/pointer_to_other.hpp>
#include <boost/type_traits/alignment_of.hpp>
#include <cstddef>
#include <boost/detail/no_exceptions_support.hpp>
#include <boost/interprocess/detail/utilities.hpp>
@@ -66,7 +63,7 @@ namespace intrusive {
//!
//! (2) when a node being deleted has two children its successor node is
//! relinked into its place, rather than copied, so that the only
//! iterators invalidated are those referring to the deleted node.
//! pointers invalidated are those referring to the deleted node.
//!
//! rbtree_algorithms is configured with a NodeTraits class, which capsulates the
//! information about the node to be manipulated. NodeTraits must support the