RFR: 8366224: Introduce DecimalDigits.appendPair for efficient two-digit formatting and refactor DateTimeHelper [v21]
Shaojin Wen
swen at openjdk.org
Fri Nov 14 14:11:22 UTC 2025
On Thu, 13 Nov 2025 16:40:45 GMT, Johannes Döbler <duke at openjdk.org> wrote:
>> Shaojin Wen has updated the pull request incrementally with one additional commit since the last revision:
>>
>> add comments
>
> src/java.base/share/classes/java/time/MonthDay.java line 758:
>
>> 756: buf.append('-');
>> 757: DecimalDigits.appendPair(buf, day);
>> 758: return buf.toString();
>
> Why not
>
> byte[] bytes = new byte[7];
> bytes[0] = (byte)'-';
> bytes[1] = (byte)'-';
> DecimalDigits.appendPair(bytes, 2, month); // TBD
> bytes[4] = (byte)'-';
> DecimalDigits.appendPair(bytes, 5, month);
> return JLA.uncheckedNewStringWithLatin1Bytes(bytes);
That's a good suggestion, but such optimization is irrelevant to this PR, or it should be done in a separate PR.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/26911#discussion_r2527645555
More information about the core-libs-dev
mailing list