RFR: 8315585: Optimization for decimal to string
Johannes Graham
duke at openjdk.org
Tue Jan 28 08:12:29 UTC 2025
On Mon, 27 Jan 2025 06:03:17 GMT, Shaojin Wen <swen at openjdk.org> wrote:
>> src/java.base/share/classes/java/math/BigDecimal.java line 3538:
>>
>>> 3536: return (signum < 0 ? "-0." : "0.").concat(intString);
>>> 3537: } else if (insertionPoint > 0) { /* Point goes inside intVal */
>>> 3538: buf = new StringBuilder();
>>
>> Could calculate the precise size for the StringBuilder
>
> The performance will degrade if you precompute the length of the StringBuilder.
That’s interesting - should the precomputed lengths be removed in the other ones as well?
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/23310#discussion_r1930371369
More information about the core-libs-dev
mailing list