mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-26 22:34:27 +02:00
8011135: (bf) CharBuffer.put(String) is slow because of String.charAt() call for each char
Reviewed-by: alanb, redestad
This commit is contained in:
parent
98ebd2bc9e
commit
b24f8ba2ec
2 changed files with 85 additions and 0 deletions
|
@ -270,6 +270,25 @@ class Heap$Type$Buffer$RW$
|
|||
#end[rw]
|
||||
}
|
||||
|
||||
#if[char]
|
||||
|
||||
public $Type$Buffer put(String src, int start, int end) {
|
||||
int length = end - start;
|
||||
checkBounds(start, length, src.length());
|
||||
if (isReadOnly())
|
||||
throw new ReadOnlyBufferException();
|
||||
int pos = position();
|
||||
int lim = limit();
|
||||
int rem = (pos <= lim) ? lim - pos : 0;
|
||||
if (length > rem)
|
||||
throw new BufferOverflowException();
|
||||
src.getChars(start, end, hb, ix(pos));
|
||||
position(pos + length);
|
||||
return this;
|
||||
}
|
||||
|
||||
#end[char]
|
||||
|
||||
public $Type$Buffer compact() {
|
||||
#if[rw]
|
||||
System.arraycopy(hb, ix(position()), hb, ix(0), remaining());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue