RFR: 8316662: Remove one allocation per conversion in Double.toString(double) and Float.toString(float) [v2]
温绍锦
duke at openjdk.org
Fri Sep 29 18:54:22 UTC 2023
On Fri, 22 Sep 2023 17:39:53 GMT, Raffaello Giulietti <rgiulietti at openjdk.org> wrote:
>> By correctly sizing an intermediate `byte[]` and making use of the internal `newStringNoRepl()` method, one allocation per conversion can be avoided when the runtime uses compact strings.
>
> Raffaello Giulietti has updated the pull request incrementally with one additional commit since the last revision:
>
> Uppercase JLA.
src/java.base/share/classes/jdk/internal/math/FloatToDecimal.java line 508:
> 506: try {
> 507: return JLA.newStringNoRepl(bytes, StandardCharsets.ISO_8859_1);
> 508: } catch (CharacterCodingException e) {
I want to know why newStringNoRepl throws CharacterCodingException instead of IllegalArgumentException. The place where I use it is forced to write redundant try_catch code.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/15861#discussion_r1341700677
More information about the core-libs-dev
mailing list