Replace Integers.checkedCast with built-in method
This commit is contained in:
parent
f0e20cf594
commit
702cf7be72
|
@ -29,7 +29,6 @@ import org.elasticsearch.common.hash.MurmurHash3;
|
||||||
import org.elasticsearch.common.io.stream.StreamInput;
|
import org.elasticsearch.common.io.stream.StreamInput;
|
||||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||||
import org.elasticsearch.common.unit.SizeValue;
|
import org.elasticsearch.common.unit.SizeValue;
|
||||||
import org.elasticsearch.common.util.primitives.Integers;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
@ -325,7 +324,7 @@ public class BloomFilter {
|
||||||
private static int size(long bits) {
|
private static int size(long bits) {
|
||||||
long quotient = bits / 64;
|
long quotient = bits / 64;
|
||||||
long remainder = bits - quotient * 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
|
// Used by serialization
|
||||||
|
|
|
@ -27,12 +27,4 @@ public class Integers {
|
||||||
Objects.requireNonNull(ints);
|
Objects.requireNonNull(ints);
|
||||||
return ints.stream().mapToInt(s -> s).toArray();
|
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue