mirror of
https://github.com/boostorg/container.git
synced 2025-08-02 05:54:28 +02:00
vector performance optimization: simplified allocator holder, constructors rewritten to avoid unnecessary initializations.
[SVN r82846]
This commit is contained in:
@@ -27,6 +27,32 @@
|
||||
|
||||
namespace boost { namespace container { namespace container_detail {
|
||||
|
||||
template<class A, class FwdIt, class Iterator>
|
||||
struct move_insert_range_proxy
|
||||
{
|
||||
typedef typename allocator_traits<A>::size_type size_type;
|
||||
typedef typename allocator_traits<A>::value_type value_type;
|
||||
|
||||
move_insert_range_proxy(A& a, FwdIt first)
|
||||
: a_(a), first_(first)
|
||||
{}
|
||||
|
||||
void uninitialized_copy_n_and_update(Iterator pos, size_type n)
|
||||
{
|
||||
this->first_ = ::boost::container::uninitialized_move_alloc_n_source
|
||||
(this->a_, this->first_, n, pos);
|
||||
}
|
||||
|
||||
void copy_n_and_update(Iterator pos, size_type n)
|
||||
{
|
||||
this->first_ = ::boost::container::move_n_source(this->first_, n, pos);
|
||||
}
|
||||
|
||||
A &a_;
|
||||
FwdIt first_;
|
||||
};
|
||||
|
||||
|
||||
template<class A, class FwdIt, class Iterator>
|
||||
struct insert_range_proxy
|
||||
{
|
||||
|
@@ -572,6 +572,62 @@ inline I copy_or_move_n_source(I f, typename std::iterator_traits<I>::difference
|
||||
return f;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// move
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template
|
||||
<typename I, // I models InputIterator
|
||||
typename F> // F models ForwardIterator
|
||||
inline F move(I f, I l, F r)
|
||||
{
|
||||
while (f != l) {
|
||||
*r = ::boost::move(*f);
|
||||
++f; ++r;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// move_n
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template
|
||||
<typename I, // I models InputIterator
|
||||
typename F> // F models ForwardIterator
|
||||
inline F move_n(I f, typename std::iterator_traits<I>::difference_type n, F r)
|
||||
{
|
||||
while (n--) {
|
||||
*r = ::boost::move(*f);
|
||||
++f; ++r;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// move_n_source
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template
|
||||
<typename I, // I models InputIterator
|
||||
typename F> // F models ForwardIterator
|
||||
inline I move_n_source(I f, typename std::iterator_traits<I>::difference_type n, F r)
|
||||
{
|
||||
while (n--) {
|
||||
*r = ::boost::move(*f);
|
||||
++f; ++r;
|
||||
}
|
||||
return f;
|
||||
}
|
||||
|
||||
} //namespace container {
|
||||
} //namespace boost {
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user