RFR: 8339290: Optimize ClassFile Utf8EntryImpl#writeTo

Chen Liang liach at openjdk.org
Fri Aug 30 04:45:21 UTC 2024


On Thu, 29 Aug 2024 14:38:20 GMT, Shaojin Wen <swen at openjdk.org> wrote:

> Use fast path for ascii characters 1 to 127 to improve the performance of writing Utf8Entry to BufferWriter.

src/java.base/share/classes/jdk/internal/access/JavaLangAccess.java line 394:

> 392:     void inflateBytesToChars(byte[] src, int srcOff, char[] dst, int dstOff, int len);
> 393: 
> 394:     boolean hasNegativeOrZeros(String s);

Can you add some javadoc? All other methods here has javadoc for usage notes.

src/java.base/share/classes/jdk/internal/classfile/impl/AbstractPoolEntry.java line 441:

> 439:                 }
> 440:                 else {
> 441:                     int charLength = stringValue.length();

In the slow loop, you can remove everything before the `else` - we don't really need that optimistic writing any more

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

PR Review Comment: https://git.openjdk.org/jdk/pull/20772#discussion_r1737913601
PR Review Comment: https://git.openjdk.org/jdk/pull/20772#discussion_r1737912744


More information about the core-libs-dev mailing list