On Tue, 27 May 2025 17:11:41 GMT, Johannes Döbler <d...@openjdk.org> wrote:

>> When debugging getLong/getDouble/getDecimal of DigitList, the debugger will 
>> call the DigitList::toString method. At this time, DigitList::toString will 
>> modify tempBuilder, which will cause incorrect results.
>
> src/java.base/share/classes/java/text/DigitList.java line 787:
> 
>> 785:         }
>> 786: 
>> 787:         return "0." + new String(digits, 0, count) + "x10^" + decimalAt;
> 
> what about
> 
>         return new StringBuilder()
>                 .append("0.")
>                 .append(digits, 0, count)
>                 .append("x10^")
>                 .append(decimalAt)
>                 .toString();
> 
> to avoid the temporary string created by `new String(digits, 0, count)`

Using the String concatenation operator looks cleaner.

In the core library, they are effectively the same, and JEP 280 Indify String 
Concatenation is not available in the core library.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/25288#discussion_r2110047144

Reply via email to