RFR: 8339699: Optimize DataOutputStream writeUTF [v3]
Shaojin Wen
swen at openjdk.org
Sat Sep 7 14:40:05 UTC 2024
On Sat, 7 Sep 2024 14:04:55 GMT, ExE Boss <duke at openjdk.org> wrote:
>> 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)`][`String::getBytes`] 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`]: https://docs.oracle.com/en/java/javase/22/docs/api/java.base/java/lang/String.html#getBytes(int,int,byte%5B%5D,int)
Although this will eliminate the warning, JDKUTF provides capabilities that are unrelated to it. What happens if a scenario other than JDKUTF is called?
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/20886#discussion_r1748198717
More information about the core-libs-dev
mailing list