Replace Integers.checkedCast with built-in method

This commit is contained in:
Jason Tedor 2015-09-17 23:36:28 -04:00
parent f0e20cf594
commit 702cf7be72
2 changed files with 1 additions and 10 deletions

View File

@ -29,7 +29,6 @@ import org.elasticsearch.common.hash.MurmurHash3;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.unit.SizeValue;
import org.elasticsearch.common.util.primitives.Integers;
import java.io.IOException;
import java.util.Arrays;
@ -325,7 +324,7 @@ public class BloomFilter {
private static int size(long bits) {
long quotient = bits / 64;
long remainder = bits - quotient * 64;
return Integers.checkedCast(remainder == 0 ? quotient : 1 + quotient);
return Math.toIntExact(remainder == 0 ? quotient : 1 + quotient);
}
// Used by serialization

View File

@ -27,12 +27,4 @@ public class Integers {
Objects.requireNonNull(ints);
return ints.stream().mapToInt(s -> s).toArray();
}
public static int checkedCast(long value) {
int cast = (int)value;
if ((long)cast != value) {
throw new IllegalArgumentException(Long.toString(value));
}
return cast;
}
}