Skip to content

Commit 9fe2927

Browse files
authored
Merge pull request #17 from bugparty/a0aj37-codex/refactor-bitvector-reserve-and-push_back-methods
Fix reserve units for bitvector
2 parents 04b1f16 + 431a643 commit 9fe2927

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

bitvector.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -356,16 +356,16 @@ namespace bowen
356356
{
357357
if (m_size == m_capacity * WORD_BITS)
358358
{
359-
reserve(m_capacity == 0 ? 1 : m_capacity * 2);
359+
reserve(m_capacity ? m_capacity * WORD_BITS * 2 : WORD_BITS);
360360
}
361361
(*this)[m_size++] = value;
362362
}
363363

364364
void reserve(size_t new_capacity)
365365
{
366-
if (new_capacity > m_capacity)
366+
if (new_capacity > m_capacity * WORD_BITS)
367367
{
368-
size_t new_word_count = num_words(new_capacity * WORD_BITS);
368+
size_t new_word_count = num_words(new_capacity);
369369

370370
BitType *new_data = m_allocator.allocate(new_word_count);
371371
std::copy(m_data, m_data + m_capacity, new_data);

0 commit comments

Comments
 (0)