On Wed, 12 Nov 2025 15:01:49 GMT, Shaojin Wen <[email protected]> wrote:

>> This PR introduces a new efficient API for appending two-digit integers to 
>> StringBuilders and refactors DateTimeHelper to leverage this new 
>> functionality.
>> 
>> Changes include:
>> 
>> 1. New `appendPair` method for efficient two-digit integer formatting 
>> (00-99):
>>    - Added `AbstractStringBuilder.appendLatin1(char c1, char c2)` with core 
>> implementation
>>    - Added `JavaLangAccess.appendPair(StringBuilder, char c1, char c2)` for 
>> internal access
>>    - Added `DecimalDigits.appendPair(StringBuilder, int)` public static 
>> utility method
>>    - Enhanced Javadoc documentation for all new methods
>> 
>> 2. Refactored `DateTimeHelper` to use the new `DecimalDigits.appendPair`:
>>    - Updated `DateTimeHelper.formatTo` methods for `LocalDate` and 
>> `LocalTime`
>>    - Replaced manual formatting logic with the new efficient two-digit 
>> appending
>>    - Improved code clarity and consistency in date/time formatting
>> 
>> These changes improve code clarity and performance when formatting two-digit 
>> numbers, particularly in date/time formatting scenarios.
>
> Shaojin Wen has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   static field JLA

test/jdk/jdk/internal/util/DecimalDigitsTest.java line 49:

> 47:             assertEquals(sb.toString(), expected, "Failed for value: " + 
> i);
> 48:         }
> 49:     }

This test is the same as the latin1 test below.  This one can be removed.

test/jdk/jdk/internal/util/DecimalDigitsTest.java line 81:

> 79:             // Check that the pair was appended correctly
> 80:             String appended = sb.substring(currentLength);
> 81:             assertEquals(appended, expected, "Failed for value: " + i + " 
> with UTF16 encoding");

I'd include the '€' in the expected string and compare the whole string.
The substring will be converted back to latin1 when it is extracted.
So much of the code involved has already been extensively tested, its not clear 
its worth the test run time.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/26911#discussion_r2519103551
PR Review Comment: https://git.openjdk.org/jdk/pull/26911#discussion_r2519128136

Reply via email to