RFR: 8320971: Use BufferedInputStream.buf directly when param of implTransferTo() is trusted [v5]

Markus KARG duke at openjdk.org
Fri Dec 8 17:26:17 UTC 2023


On Fri, 8 Dec 2023 15:46:31 GMT, Sergey Tsypanov <stsypanov at openjdk.org> wrote:

>> It looks like we can skip copying of `byte[]` in `BufferedInputStream.implTransferTo()` for `OutputStreams` residing in `java.io`.
>> 
>> See comment by @vlsi in https://github.com/openjdk/jdk/pull/10525/files#diff-e19c508d1bb6ee78697ecca66947c395adda0d9c49a85bf696e677ecbd977af1R612
>
> Sergey Tsypanov has updated the pull request incrementally with one additional commit since the last revision:
> 
>   8320971: Use same approach as BAOS

src/java.base/share/classes/java/io/OutputStream.java line 212:

> 210:      * @return true if the argument of {@link #write(byte[])}} and {@link #write(byte[], int, int)}} needn't be copied
> 211:      */
> 212:     boolean trusted() {

This is a strange construction. Any subclass could simply implement this as `return true;`. Where is the guard against this, and why not doing it that way?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/16879#discussion_r1420812353


More information about the core-libs-dev mailing list