RFR: 8306374: (bf) Improve performance of DirectCharBuffer::append(CharSequence[,int,int])

Chen Liang liach at openjdk.org
Wed Apr 19 15:45:47 UTC 2023


On Wed, 19 Apr 2023 00:29:14 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:

> Use `getChars()` to copy characters to an intermediate local `char[]` array and then `putArray()` to copy the chars into the buffer itself.

src/java.base/share/classes/java/nio/Direct-X-Buffer.java.template line 461:

> 459:             throw new BufferOverflowException();
> 460: 
> 461:         char[] buf = new char[APPEND_BUF_SIZE];

Can we do Math.min(length, APPEND_BUF_SIZE) here?

src/java.base/share/classes/java/nio/Direct-X-Buffer.java.template line 489:

> 487:     public $Type$Buffer append(CharSequence csq) {
> 488: #if[rw] 
> 489:         if (csq instanceof StringBuilder) 

Why don't we check for string or stringbuffer here?

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/13522#discussion_r1171521476
PR Review Comment: https://git.openjdk.org/jdk/pull/13522#discussion_r1171525408


More information about the nio-dev mailing list