RFR: 8341470: BigDecimal.stripTrailingZeros() optimization [v42]
j3graham
duke at openjdk.org
Sun Oct 13 17:51:13 UTC 2024
On Sun, 13 Oct 2024 17:48:15 GMT, j3graham <duke at openjdk.org> wrote:
>> src/java.base/share/classes/java/math/BigDecimal.java line 5234:
>>
>>> 5232: */
>>> 5233: private static BigInteger fiveToTwoToThe(int n) {
>>> 5234: int i = Math.min(n, FIVE_TO_2_TO.length - 1);
>>
>> BigInteger has “getRadixConversionCache” which could be made accessible and used here - perhaps with a better name.
>
>> @j3graham The benchmarks using `getRadixConversionCache()` look good (see below). The problem with this is that the cache maintained by that method is unlimited, whereas the one controlled by `fiveToTwoToThe()` has modest memory requirements.
>>
>> ```
>
> The method here could use the radix cache up to a safe value, and continue the calculation as it currently does beyond that. The benefit would be the existing incremental evaluation.
> I already wrote about that method previously [here](https://github.com/openjdk/jdk/pull/21323#discussion_r1790787304).
Sorry, missed that comment.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/21323#discussion_r1798470618
More information about the core-libs-dev
mailing list