RFR: 8339699: Optimize DataOutputStream writeUTF [v3]

Shaojin Wen swen at openjdk.org
Fri Sep 13 17:38:56 UTC 2024


On Fri, 13 Sep 2024 17:05:11 GMT, Chen Liang <liach 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/jdk/internal/util/JDKUTF.java line 37:
> 
>> 35: public abstract class JDKUTF {
>> 36:     @ForceInline
>> 37:     public static int putChar(byte[] buf, int offset, char c) {
> 
> Do you think we can just move the loop here, like:
> 
> public static int putChars(byte[] buf, int offset, String str, int strStart, int strEnd) {
>     for (int i = strStart; i < strEnd; i++) {
>         offset = putChar(buf, offset, str.charAt(i);
>     }
> }
> 
> We can even unroll putChar in the loop.

This does not work in ObjectOutputStream#writeMoreUTF

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

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


More information about the core-libs-dev mailing list