Skip to content

Commit

Permalink
remove possible bitshifts of negative numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
lroberts36 committed Jun 13, 2024
1 parent 6268f2c commit be633cd
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/mesh/forest/logical_location.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,10 @@ bool LogicalLocation::IsNeighbor(const LogicalLocation &in) const {

bool neighbors = true;
for (int dir = 0; dir < 3; ++dir) {
auto low = (l(dir) << level_shift_this) - 1;
auto low = l(dir) * block_size_this - 1;
auto hi = low + block_size_this + 1;

auto low_in = (in.l(dir) << level_shift_in);
auto low_in = in.l(dir) * block_size_in;
auto hi_in = low_in + block_size_in - 1;
neighbors = neighbors && !(hi < low_in || low > hi_in);
}
Expand All @@ -140,7 +140,7 @@ bool LogicalLocation::IsNeighborOfTE(const LogicalLocation &in,

bool neighbors = true;
for (int dir = 0; dir < 3; ++dir) {
auto low = (l(dir) << level_shift_this);
auto low = l(dir) * block_size_this;
auto hi = low + block_size_this - 1;
if (te_offset[dir] == -1) {
low -= 1;
Expand All @@ -150,7 +150,7 @@ bool LogicalLocation::IsNeighborOfTE(const LogicalLocation &in,
low = hi - 1;
}

auto low_in = (in.l(dir) << level_shift_in);
auto low_in = in.l(dir) * block_size_in;
auto hi_in = low_in + block_size_in - 1;
neighbors = neighbors && !(hi < low_in || low > hi_in);
}
Expand Down

0 comments on commit be633cd

Please sign in to comment.