8229845: Decrease memory consumption of BigInteger.toString()

Brian Burkhalter brian.burkhalter at oracle.com
Thu Aug 22 00:28:47 UTC 2019


> On Aug 20, 2019, at 4:31 PM, Brian Burkhalter <brian.burkhalter at oracle.com> wrote:
>> On Aug 20, 2019, at 2:45 PM, Ivan Gerasimov <ivan.gerasimov at oracle.com <mailto:ivan.gerasimov at oracle.com>> wrote:
>> Would it make sense to add an argument `digits` to smallToString (like the same named argument of toString, the minimum number of digits to pad to), so it could zero-pad the result itself?
>> This way we could avoid inserting zeros into the middle of a StringBuilder after a call to smallToString.
> Indeed I do not like the zero insertion either. I’ll investigate your idea.

I modified the patch so that characters are exclusively appended to the StringBuilder thereby eliminating copying of characters which are already present after the insertion point, viz., the padding with zeros after calling smallToString() in the recursive path. A delta versus version .01 is at [1] and the diff versus the tip at [2].



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

More information about the core-libs-dev mailing list