8270160: Remove redundant bounds check from AbstractStringBuilder.charAt()

Reviewed-by: redestad
This commit is contained in:
Sergey Tsypanov 2021-08-02 12:48:35 +00:00 committed by Claes Redestad
parent 6c4c48faea
commit 2536e4342e
2 changed files with 1 additions and 4 deletions

View File

@ -349,9 +349,8 @@ abstract class AbstractStringBuilder implements Appendable, CharSequence {
*/
@Override
public char charAt(int index) {
checkIndex(index, count);
if (isLatin1()) {
return (char)(value[index] & 0xff);
return StringLatin1.charAt(value, index);
}
return StringUTF16.charAt(value, index);
}

View File

@ -27,11 +27,9 @@ package java.lang;
import java.util.Arrays;
import java.util.Locale;
import java.util.Objects;
import java.util.Spliterator;
import java.util.function.Consumer;
import java.util.function.IntConsumer;
import java.util.stream.IntStream;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
import jdk.internal.util.ArraysSupport;