8229845: Decrease memory consumption of BigInteger.toString()
brian.burkhalter at oracle.com
Fri Aug 23 17:11:15 UTC 2019
> 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:  delta,  absolute. I also increased the size of some of the values tested at line 798 of BigIntegerTest.
More information about the core-libs-dev