8229845: Decrease memory consumption of BigInteger.toString()

Brian Burkhalter brian.burkhalter at oracle.com
Fri Aug 23 17:11:15 UTC 2019

Hi Ivan,

> On Aug 22, 2019, at 1:24 PM, Ivan Gerasimov <ivan.gerasimov at oracle.com> wrote:
> I have a few further suggestions how to simplify the code.
> […]

Those are all good suggestions: thanks!

> Here's the patch, which illustrates all the suggestions above:
> http://cr.openjdk.java.net/~igerasim/8229845/00/webrev/ <http://cr.openjdk.java.net/~igerasim/8229845/00/webrev/>
> (I have only run the tests from test/jdk/java/math/BigInteger to verify it).

This patch has a problem:
4023         padWithZeros(buf, digits - s.length() + (numGroups - 1) * digitsPerLong[radix]);
It is missing parentheses:

4023         padWithZeros(buf, digits - (s.length() + (numGroups - 1) * digitsPerLong[radix]));

I was unable to find this by debugging but implemented your suggestions by hand and then found it by diff-ing the patches. My updated versions with your suggestions incorporated are: [1] delta, [2] absolute. I also increased the size of some of the values tested at line 798 of BigIntegerTest.



[1] http://cr.openjdk.java.net/~bpb/8229845/webrev.03-04/
[2] http://cr.openjdk.java.net/~bpb/8229845/webrev.04/

More information about the core-libs-dev mailing list