File tree Expand file tree Collapse file tree 2 files changed +12
-3
lines changed
Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change 1+ build /
Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ namespace bowen
2929 if (n > std::numeric_limits<std::size_t >::max () / sizeof (T)) {
3030 throw std::bad_alloc ();
3131 }
32-
32+
3333 void *ptr = _mm_malloc (n * sizeof (T), ALIGN_SIZE);
3434 if (!ptr) {
3535 throw std::bad_alloc ();
@@ -358,15 +358,23 @@ namespace bowen
358358 {
359359 reserve (m_capacity ? m_capacity * WORD_BITS * 2 : WORD_BITS);
360360 }
361- (*this )[m_size++] = value;
361+
362+ size_t word_index = m_size >> WORD_SHIFT;
363+ BitType mask = static_cast <BitType>(1 )
364+ << (m_size & (WORD_BITS - 1 ));
365+ if (value)
366+ m_data[word_index] |= mask;
367+ else
368+ m_data[word_index] &= ~mask;
369+ ++m_size;
362370 }
363371
364372 void reserve (size_t new_capacity)
365373 {
366374 if (new_capacity > m_capacity * WORD_BITS)
367375 {
368376 size_t new_word_count = num_words (new_capacity);
369-
377+
370378 BitType *new_data = m_allocator.allocate (new_word_count);
371379 std::copy (m_data, m_data + m_capacity, new_data);
372380 deallocate_memory ();
You can’t perform that action at this time.
0 commit comments