Skip to content

Commit

Permalink
Fix BlockArray size method
Browse files Browse the repository at this point in the history
  • Loading branch information
ajtribick committed Jul 6, 2024
1 parent e5da024 commit 7783ffe
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions src/celutil/blockarray.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,7 @@ class BlockArray
{
if (m_blocks.empty())
return 0;
// For power-of-two sizes we can use bitwise OR instead of addition
if constexpr ((BLOCKSIZE & (BLOCKSIZE - 1)) == 0)
return ((m_blocks.size() - 1) * BLOCKSIZE) | m_blocks.back()->size();
else
return ((m_blocks.size() - 1) * BLOCKSIZE) + m_blocks.back()->size();
return ((m_blocks.size() - 1) * BLOCKSIZE) + m_blocks.back()->size();
}

size_type max_size() const noexcept { return static_cast<size_type>(std::numeric_limits<difference_type>::max()); }
Expand Down

0 comments on commit 7783ffe

Please sign in to comment.