diff options
Diffstat (limited to 'libartbase/base/bit_vector.cc')
-rw-r--r-- | libartbase/base/bit_vector.cc | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/libartbase/base/bit_vector.cc b/libartbase/base/bit_vector.cc index 8e3d4c9bf7..d3cb652c0c 100644 --- a/libartbase/base/bit_vector.cc +++ b/libartbase/base/bit_vector.cc @@ -376,4 +376,31 @@ Allocator* BitVector::GetAllocator() const { return allocator_; } +void BaseBitVectorArray::Resize(size_t rows, size_t cols, bool clear) { + DCHECK(IsExpandable()); + if (clear) { + Clear(); + } + cols = RoundUp(cols, BitVector::kWordBits); + num_columns_ = cols; + num_rows_ = rows; + // Ensure size + GetRawData().SetBit(num_rows_ * num_columns_ - 1); + GetRawData().ClearBit(num_rows_ * num_columns_ - 1); +} + +// In order to improve performance we do this in 4-byte blocks. Clang should be +// able to optimize this to larger blocks if possible. +void BaseBitVectorArray::UnionRows(size_t dest_row, size_t other) { + DCHECK_LT(dest_row, num_rows_); + DCHECK_LT(other, num_rows_); + size_t block_words = num_columns_ / BitVector::kWordBits; + uint32_t* dest = + GetRawData().GetRawStorage() + ((dest_row * num_columns_) / BitVector::kWordBits); + uint32_t* source = GetRawData().GetRawStorage() + ((other * num_columns_) / BitVector::kWordBits); + for (uint32_t i = 0; i < block_words; ++i, ++dest, ++source) { + *dest = (*dest) | (*source); + } +} + } // namespace art |