8229845: Decrease memory consumption of BigInteger.toString()
ivan.gerasimov at oracle.com
Tue Aug 20 17:28:58 UTC 2019
While we're here.
On 8/20/19 1:05 AM, Aleksey Shipilev wrote:
> *) This might be "static final", while we are at it:
> 4109 private static String zeros = new String;
It may make sense to create the only string as
private static final String zeros = "0".repeat(63);
and then replace all
sb.append(zeros[x]) with sb.append(zeros, 0, x) and
sb.insert(pos, zeros[x]) with sb.insert(pos, zeros, 0, x).
The difference would be in one extra bounds check, and as both append()
and insert() are relatively expensive, this check would hardly be
With kind regards,
More information about the core-libs-dev