mirror of
https://github.com/boostorg/container.git
synced 2025-08-01 21:44:27 +02:00
Add unused_storage optimization function
This commit is contained in:
@@ -2170,6 +2170,28 @@ class devector
|
||||
|| allocator_traits_type::is_always_equal::value)
|
||||
{ x.swap(y); }
|
||||
|
||||
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
|
||||
//Functions for optimizations, not for users
|
||||
T *unused_storage(size_type &size)
|
||||
{
|
||||
T *const storage_addr = boost::movelib::to_raw_pointer(m_.buffer);
|
||||
if(this->empty()){
|
||||
size = m_.capacity;
|
||||
return storage_addr;
|
||||
}
|
||||
else if(this->back_free_capacity() > this->front_free_capacity()){
|
||||
size = this->back_free_capacity();
|
||||
return storage_addr + m_.back_idx;
|
||||
}
|
||||
else{
|
||||
size = this->front_free_capacity();
|
||||
return storage_addr;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
||||
void priv_move_assign(BOOST_RV_REF(devector) x, dtl::bool_<true> /*steal_resources*/)
|
||||
|
@@ -2394,6 +2394,14 @@ private:
|
||||
boost::movelib::adaptive_merge( this->begin(), pos, e, comp
|
||||
, this->priv_raw_end(), this->capacity() - this->size());
|
||||
}
|
||||
|
||||
//Function for optimizations, not for users
|
||||
T *unused_storage(size_type &size)
|
||||
{
|
||||
size = static_cast<size_type>(this->capacity() - this->size());
|
||||
return this->priv_raw_end();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
Reference in New Issue
Block a user