Skip to content

Commit

Permalink
Remove useless asserts, and migrate an error closer to API
Browse files Browse the repository at this point in the history
  • Loading branch information
niloc132 committed Sep 6, 2024
1 parent bbd8e7f commit 8ce55b5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ public class JsRangeSet {
private final RangeSet range;

public static JsRangeSet ofRange(double first, double last) {
if (first > last) {
throw new IllegalStateException(first + " > " + last);
}
return new JsRangeSet(RangeSet.ofRange((long) first, (long) last));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
package io.deephaven.web.shared.data;

import javax.annotation.Nonnull;
import java.io.Serializable;

/**
* Describes a contiguous range of at least one item. Equals/hashcode compare both start and end, but comparing Range
Expand All @@ -15,15 +14,7 @@ public class Range implements Comparable<Range> {
private final long first;
private final long last;

// serialization
Range() {
this(0, 0);
}

public Range(long first, long last) {
if (first > last) {
throw new IllegalStateException(first + " > " + last);
}
this.first = first;
this.last = last;
}
Expand Down Expand Up @@ -70,13 +61,10 @@ public Range[] minus(Range range) {
// otherwise either the subtracted section's start is within our range _or_ its end is within our range,
// and we can use that to only produce the one range we need to return
if (range.first <= first) {
assert range.last >= first : "removed range expected to not end before existing range";
return new Range[] {
new Range(range.last + 1, last)
};
} else {
assert range.last >= last : "removed range expected to end by the end of the existing range";
assert range.first <= last : "removed range expected to start before existing range";
return new Range[] {
new Range(first, range.first - 1)
};
Expand Down

0 comments on commit 8ce55b5

Please sign in to comment.