Skip to content

Commit

Permalink
Followup to Devin's comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
jcferretti committed Mar 11, 2022
1 parent d6bab10 commit 80fc422
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,9 @@ public final OrderedLongSet ixRemove(final long key) {
}

private static long addSaturated(final long x, final long y) {
// we know x >= 0, y >= 0.
final long res = x + y;
if (res < x) {
if (res < 0) {
return Long.MAX_VALUE;
}
return res;
Expand All @@ -227,7 +228,7 @@ public final OrderedLongSet ixSubindexByPosOnNew(final long startPos, final long
return ixCowRef();
}
return make(
Math.max(addSaturated(rangeStart(), startPos), rangeStart()),
addSaturated(rangeStart(), startPos),
Math.min(addSaturated(rangeStart(), endPos), rangeEnd()));
}

Expand Down

0 comments on commit 80fc422

Please sign in to comment.