RFR: 8334328: Reduce object allocation for FloatToDecimal and DoubleToDecimal [v18]
Shaojin Wen
duke at openjdk.org
Wed Jun 26 13:26:12 UTC 2024
On Wed, 26 Jun 2024 13:14:13 GMT, Claes Redestad <redestad at openjdk.org> wrote:
>> Shaojin Wen has updated the pull request incrementally with one additional commit since the last revision:
>>
>> from @liach: use s.getBytes for performance
>
> src/java.base/share/classes/jdk/internal/math/ToDecimal.java line 47:
>
>> 45: static final int NAN = 5 << 8;
>> 46:
>> 47: static final byte LATIN1 = 0;
>
> I think this somewhat unnecessarily copies names and internal implementation details from `String` (where the `coder` value is used both as a pseudo-boolean and as a shift operand, which is not applicable here). In this context we could use something like `private final boolean latin1;` (all uses of `coder` are just `if (coder == LATIN1)` so it would be simplified to `if (latin1)`)
I have written a version using boolean locally, but because this class is mainly used by String and StringBuilder, it uses the same style as String/StringBuilder.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/19730#discussion_r1654832167
More information about the core-libs-dev
mailing list