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

Brian Burkhalter bpb at openjdk.org
Wed Apr 19 15:59:51 UTC 2023


On Wed, 19 Apr 2023 15:42:33 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:

>> 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?
>
> In the development of #13415 we found that those cases were not improved by the heap buffer override, but I think you are correct in that that change should also be measured before we throw it out.

Changing this to also allow `String` and `StringBuffer` does not improve throughput. The reasons are that both of these use the already optimized case of putting a `String` and their `toString()` methods do not copy.

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

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


More information about the nio-dev mailing list