On Sat, 7 Sep 2024 08:51:25 GMT, Shaojin Wen <s...@openjdk.org> wrote:

>> PR #20772 introduced an optimization for writeUTF, which can also be used in 
>> DataOutputStream::writeUTF.
>
> Shaojin Wen has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   reduce JDKUTF#utflen codeSize

src/java.base/share/classes/java/io/DataOutputStream.java line 382:

> 380:         ByteArray.setUnsignedShort(bytearr, count, utflen);
> 381:         count += 2;
> 382:         str.getBytes(0, countNonZeroAscii, bytearr, count);

Maybe the deprecated [`String​::getBytes​(int, int, byte[], int)`] method calls 
could be moved to a method in `JDKUTF` in order to avoid having to use overly 
broad `@SuppressWarnings("deprecation")`:

@ForceInline
@SuppressWarnings("deprecation")
public static void getBytes(String str, int srcPos, byte[] dst, int dstPos, int 
length) {
        str.getBytes(srcPos, srcPos + length, dst, dstPos);
}


[`String​::getBytes​(int, int, byte[], int)`]: 
https://docs.oracle.com/en/java/javase/22/docs/api/java.base/java/lang/String.html#getBytes(int,int,byte[],int)

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

PR Review Comment: https://git.openjdk.org/jdk/pull/20886#discussion_r1748098802

Reply via email to