mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
8305811: (bf) Improve performance of CharBuffer::append(CharSequence[,int,int])
Reviewed-by: alanb
This commit is contained in:
parent
525a91e3fa
commit
8858d54342
3 changed files with 205 additions and 1 deletions
|
@ -2005,6 +2005,8 @@ public abstract sealed class $Type$Buffer
|
|||
public $Type$Buffer append(CharSequence csq) {
|
||||
if (csq == null)
|
||||
return put("null");
|
||||
else if (csq instanceof CharBuffer cb)
|
||||
return put(cb);
|
||||
else
|
||||
return put(csq.toString());
|
||||
}
|
||||
|
@ -2042,6 +2044,13 @@ public abstract sealed class $Type$Buffer
|
|||
* @since 1.5
|
||||
*/
|
||||
public $Type$Buffer append(CharSequence csq, int start, int end) {
|
||||
if (csq instanceof CharBuffer cb) {
|
||||
int pos = position();
|
||||
int length = end - start;
|
||||
put(pos, cb, start, length);
|
||||
position(pos + length);
|
||||
return this;
|
||||
}
|
||||
CharSequence cs = (csq == null ? "null" : csq);
|
||||
return put(cs.subSequence(start, end).toString());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue