8276806: Use Objects.checkFromIndexSize where possible in java.base

Reviewed-by: rriggs, lancea
This commit is contained in:
Sergey Tsypanov 2021-12-02 20:00:49 +00:00 committed by Roger Riggs
parent 30087cc1b8
commit 73a9654c26
11 changed files with 40 additions and 43 deletions

View file

@ -430,9 +430,7 @@ abstract class AbstractStringBuilder implements Appendable, CharSequence {
* {@code beginIndex} is larger than {@code endIndex}.
*/
public int codePointCount(int beginIndex, int endIndex) {
if (beginIndex < 0 || endIndex > count || beginIndex > endIndex) {
throw new IndexOutOfBoundsException();
}
Preconditions.checkFromToIndex(beginIndex, endIndex, length(), null);
if (isLatin1()) {
return endIndex - beginIndex;
}