8254082: AbstractStringBuilder.insert(int dstOffset, CharSequence s, int start, int end) is missing fast-path for String

Reviewed-by: redestad
This commit is contained in:
Sergey Tsypanov 2020-11-30 17:43:19 +00:00 committed by Claes Redestad
parent 4c86e46d75
commit 6eb25d7cb4
2 changed files with 37 additions and 13 deletions

View file

@ -3599,7 +3599,7 @@ public final class String
* @param dstBegin the char index, not offset of byte[]
* @param coder the coder of dst[]
*/
void getBytes(byte dst[], int dstBegin, byte coder) {
void getBytes(byte[] dst, int dstBegin, byte coder) {
if (coder() == coder) {
System.arraycopy(value, 0, dst, dstBegin << coder, value.length);
} else { // this.coder == LATIN && coder == UTF16
@ -3607,6 +3607,26 @@ public final class String
}
}
/**
* Copy character bytes from this string into dst starting at dstBegin.
* This method doesn't perform any range checking.
*
* Invoker guarantees: dst is in UTF16 (inflate itself for asb), if two
* coders are different, and dst is big enough (range check)
*
* @param srcPos the char index, not offset of byte[]
* @param dstBegin the char index to start from
* @param coder the coder of dst[]
* @param length the amount of copied chars
*/
void getBytes(byte[] dst, int srcPos, int dstBegin, byte coder, int length) {
if (coder() == coder) {
System.arraycopy(value, srcPos, dst, dstBegin << coder, length << coder());
} else { // this.coder == LATIN && coder == UTF16
StringLatin1.inflate(value, srcPos, dst, dstBegin, length);
}
}
/*
* Package private constructor. Trailing Void argument is there for
* disambiguating it against other (public) constructors.