From 80fc4220649405bdd95612ca73d744eaf5c127eb Mon Sep 17 00:00:00 2001 From: Cristian Ferretti Date: Fri, 11 Mar 2022 16:18:13 -0500 Subject: [PATCH] Followup to Devin's comments. --- .../engine/rowset/impl/singlerange/SingleRange.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/engine/rowset/src/main/java/io/deephaven/engine/rowset/impl/singlerange/SingleRange.java b/engine/rowset/src/main/java/io/deephaven/engine/rowset/impl/singlerange/SingleRange.java index c53dcbcbbc8..f0c45b5e1d9 100644 --- a/engine/rowset/src/main/java/io/deephaven/engine/rowset/impl/singlerange/SingleRange.java +++ b/engine/rowset/src/main/java/io/deephaven/engine/rowset/impl/singlerange/SingleRange.java @@ -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; @@ -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())); }