RFR: 8338937: Optimize the string concatenation of ClassDesc

Shaojin Wen duke at openjdk.org
Sun Aug 25 21:10:03 UTC 2024


On Sun, 25 Aug 2024 16:55:23 GMT, ExE Boss <duke at openjdk.org> wrote:

>> Optimize ClassDesc related string concatenation, which will reduce object allocation during startup.
>
> src/java.base/share/classes/java/lang/StringConcatHelper.java line 787:
> 
>> 785:     }
>> 786: 
>> 787:     static String concat(String prefix, String value, String suffix) {
> 
> `Class​::descriptorString()` can probably also make use of this method and `String​::concat​(String)`:
> 
> if (isArray()) {
> 	return "[".concat(componentType.descriptorString());
> } else if (isHidden()) {
> 	// unchanged
> } else {
> 	String name = getName().replace('.', '/');
> 	return StringConcatHelper.concat("L", name, ";");
> }

In this case, there are too many locations under the java.lang package to change, and a new PR may be more appropriate.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/20705#discussion_r1730430947


More information about the core-libs-dev mailing list