mirror of
https://github.com/boostorg/dynamic_bitset.git
synced 2026-01-19 04:12:09 +00:00
Make push_back() more efficient
This commit is contained in:
@@ -750,8 +750,13 @@ void
|
|||||||
dynamic_bitset< Block, AllocatorOrContainer >::
|
dynamic_bitset< Block, AllocatorOrContainer >::
|
||||||
push_back( bool bit )
|
push_back( bool bit )
|
||||||
{
|
{
|
||||||
const size_type sz = size();
|
const int extra_bits = count_extra_bits();
|
||||||
resize( sz + 1, bit );
|
if ( extra_bits == 0 ) {
|
||||||
|
m_bits.push_back( Block( bit ) );
|
||||||
|
} else {
|
||||||
|
m_bits.back() |= ( Block( bit ) << extra_bits );
|
||||||
|
}
|
||||||
|
++ m_num_bits;
|
||||||
}
|
}
|
||||||
|
|
||||||
template< typename Block, typename AllocatorOrContainer >
|
template< typename Block, typename AllocatorOrContainer >
|
||||||
|
|||||||
Reference in New Issue
Block a user