RFR: 8341402: BigDecimal's square root optimization [v17]

Raffaello Giulietti rgiulietti at openjdk.org
Mon Nov 18 14:23:49 UTC 2024


On Mon, 18 Nov 2024 14:11:43 GMT, Raffaello Giulietti <rgiulietti at openjdk.org> wrote:

>> fabioromano1 has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Optimize sqrt branch for exact results
>
> src/java.base/share/classes/java/math/BigDecimal.java line 2248:
> 
>> 2246:                             }
>> 2247:                         }
>> 2248:                     } else { // mc.roundingMode == RoundingMode.UP || mc.roundingMode == RoundingMode.CEILING
> 
> It would be more robust to make all enum constant explicit, and reserve the `else` to throw a `RuntimeException` of some sort, e.g., `MatchException`. Should an additional enum constant be added to `RoundingMode` in the future, this code will then throw instead of silently producing a wrong result.
> 
> If possible at all, it would be preferable to use a `switch` rather than `if`s.

Also, please merge master into this.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/21301#discussion_r1846673296


More information about the core-libs-dev mailing list