RFR: 8358880: Performance of parsing with DecimalFormat can be improved [v3]
Raffaello Giulietti
rgiulietti at openjdk.org
Wed Jul 30 13:43:00 UTC 2025
On Mon, 16 Jun 2025 18:19:29 GMT, Justin Lu <jlu at openjdk.org> wrote:
>> I don't have a specific example, so I've reverted to my original check. I'm a bit unsettled by the check for an extreme value later in `doubleValue()` comparing against `MIN_DECIMAL_EXPONENT - 1`
>
> IMO, the original check you had is easier to understand what is happening without further context, so I prefer your switch back.
>
> I think we are fine from (negative) "extreme values" in `doubleValue()` because of the check you have implemented in the first place. i.e. we avoid any potential underflow from `int exp = decExponent - kDigits;`. I think we do need a comment to accompany the check. (Why do we check? why not check the max exponent value?)
>
> Also, should the check be against `MIN_DECIMAL_EXPONENT - 1` for consistency with `doubleValue()`? (Functionally, I don't think it matters.)
Suggestion:
if (decExp <= MIN_DECIMAL_EXPONENT) {
This is just a note for future enhancements. No need for a new commit, as the current version is correct and avoids the underflow in `doubleValue()`.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/25644#discussion_r2242727180
More information about the core-libs-dev
mailing list