On Wed, 22 Oct 2025 17:55:16 GMT, Johannes Graham <[email protected]> wrote:

>> With the introduction of String.newStringWithLatin1Bytes, we can use it to 
>> simplify the toString methods of Integer and Long. By replacing the 
>> implementation that supports COMPACT_STRING = false with 
>> newStringWithLatin1Bytes, we gain the following benefits:
>> 1. Simplified implementation
>> 2. Strings with codeSize < 35 in Integer.toString(int) and 
>> Long.toString(long) can be inlined in C1, improving performance in early 
>> calls.
>
> src/java.base/share/classes/java/lang/Integer.java line 366:
> 
>> 364:         int mag = Integer.SIZE - Integer.numberOfLeadingZeros(val);
>> 365:         int chars = Math.max(((mag + (shift - 1)) / shift), 1);
>> 366:         byte[] buf = new byte[chars];
> 
> Should the array size be `chars*2` in when compact strings is not in use?

There is no need to handle the case where COMPACT_STRING false is used, as it 
is inflate in java.lang.String#newStringWithLatin1Bytes.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/27929#discussion_r2453702861

Reply via email to