RFR: 8367324: Avoid redundant parsing when formatting with DigitList [v3]

Raffaello Giulietti rgiulietti at openjdk.org
Wed Sep 24 09:51:23 UTC 2025


On Fri, 12 Sep 2025 22:44:54 GMT, Johannes Graham <duke at openjdk.org> wrote:

>> When formatting doubles or BigDecimals, DigitList first formats them as a string and then parses the resultant string to extract the mantissa and the exponent. This can be done more directly. This allows removing some parsing code and removes a cached byte array.
>> 
>> This also facilitates potential cleanups in FloatingDecimal (removal of getChars method) but I've left that for later to minimize conflicts with other changes there.
>
> Johannes Graham has updated the pull request incrementally with one additional commit since the last revision:
> 
>   VALUES_SIZE

Otherwise looks good

src/java.base/share/classes/java/text/DigitList.java line 326:

> 324:         boolean hasBeenRoundedUp = fdConverter.digitsRoundedUp();
> 325:         boolean valueExactAsDecimal = fdConverter.decimalDigitsExact();
> 326:         assert !fdConverter.isExceptional();

Maybe move this `assert` line at method entry.

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

PR Review: https://git.openjdk.org/jdk/pull/27118#pullrequestreview-3261696562
PR Review Comment: https://git.openjdk.org/jdk/pull/27118#discussion_r2374926890


More information about the core-libs-dev mailing list