[jdk8u-dev] RFR: 8299677: Formatter.format might take a long time to format an integer or floating-point [v2]

Aleksey Shipilev shade at openjdk.org
Tue Feb 27 19:04:53 UTC 2024


On Tue, 27 Feb 2024 18:52:06 GMT, Chad Rakoczy <duke at openjdk.org> wrote:

>> Backport of [JDK-8299677](https://bugs.openjdk.org/browse/JDK-8299677)
>> 
>> Backport was not clean. Rewrote test to not include junit `ParameterizedTest`. Rewrote fix since `String.repeat` is not in JDK8
>
> Chad Rakoczy has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Update Formatter zero padding

jdk/src/share/classes/java/util/Formatter.java line 4386:

> 4384:                 char[] zeros = new char[width - len];
> 4385:                 Arrays.fill(zeros, zero);
> 4386:                 sb.insert(begin, new String(zeros));

Oh wait, we actually have `StringBuilder.insert(char[],int)`! That's useful, we don't need to do `new String()` then?

-------------

PR Review Comment: https://git.openjdk.org/jdk8u-dev/pull/459#discussion_r1504788794


More information about the jdk8u-dev mailing list