Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use (0 - x) instead of (~x - 1) for -x #34

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/marisa/grimoire/vector/bit-vector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,7 @@ void BitVector::build_index(const BitVector &bv,
const std::size_t unit_num_0s =
std::min<std::size_t>(bits_remaining, MARISA_WORD_SIZE) - unit_num_1s;

const std::size_t zero_bit_id = (~num_0s + 1) % 512;
const std::size_t zero_bit_id = (0 - num_0s) % 512;
jmr marked this conversation as resolved.
Show resolved Hide resolved
if (unit_num_0s > zero_bit_id) {
// select0s_ is UInt32, but select_bit returns size_t, so cast to
// suppress narrowing conversion warning. push_back checks the
Expand All @@ -795,7 +795,7 @@ void BitVector::build_index(const BitVector &bv,
}

if (enables_select1) {
const std::size_t one_bit_id = (~num_1s + 1) % 512;
const std::size_t one_bit_id = (0 - num_1s) % 512;
if (unit_num_1s > one_bit_id) {
select1s_.push_back(
static_cast<UInt32>(select_bit(one_bit_id, bit_id, unit)));
Expand Down