RFR: 8331264: Reduce java.lang.constant initialization overhead [v2]

Claes Redestad redestad at openjdk.org
Mon Apr 29 12:27:17 UTC 2024


On Mon, 29 Apr 2024 12:18:15 GMT, Chen Liang <liach at openjdk.org> wrote:

>> Claes Redestad has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Descriptors can't be empty, optimize isArray and isClassOrInterface with descriptorString().charAt(0) ==
>
> src/java.base/share/classes/java/lang/constant/MethodTypeDescImpl.java line 74:
> 
>> 72: 
>> 73:         for (ClassDesc cd : trustedArgTypes)
>> 74:             if (cd.descriptorString().equals("V")) // implicit null check
> 
> Just curious, is `equals` faster than `charAt(0) ==` for single-char strings?

I've not benchmarked this detail in JMH, only verified it does less work when interpreted. We could probably just drop `cd.isPrimitive() &&`, though, since a descriptor of length > 1 starting with `V` can't be created.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/18991#discussion_r1583007082


More information about the core-libs-dev mailing list