RFR: 8316704: Regex-free parsing of Formatter and FormatProcessor specifiers
Shaojin Wen
duke at openjdk.org
Mon Oct 16 16:18:21 UTC 2023
On Mon, 18 Sep 2023 00:48:26 GMT, Shaojin Wen <duke at openjdk.org> wrote:
>> src/java.base/share/classes/java/util/Formatter.java line 3420:
>>
>>> 3418: && fmt.a instanceof StringBuilder sb
>>> 3419: ) {
>>> 3420: sb.append(value);
>>
>> There's a lot of `if`s here, and this doesn't take into account locales with non-ASCII digits:
>>
>> Locale ar = new Locale.Builder().setLanguageTag("ar-SA-u-nu-arab").build();
>> Locale.setDefault(ar);
>> System.out.println("%d".formatted(10000)); // should print "١٠٠٠٠" but prints "10000"
>
> The change code of print fast-path has been deleted, and parse fast-path has added support for the pattern "%8.3f".
>
> Where to draw the line of parse fast-path? I have seen patterns that cause performance problems, and they can be easily implemented, so I added them.
Now parse fast-path supports "8.3f", but not "10.3". Because the fast-path method code size should be less than 325, for JIT inline
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/15776#discussion_r1328210418
More information about the core-libs-dev
mailing list