On Wed, 27 Aug 2025 11:45:09 GMT, Mikhail Yankelevich 
<myankelev...@openjdk.org> wrote:

>> Shaojin Wen has updated the pull request with a new target base due to a 
>> merge or a rebase. The pull request now contains six commits:
>> 
>>  - Merge remote-tracking branch 'upstream/master' into appendPair_202508
>>    
>>    # Conflicts:
>>    # src/java.base/share/classes/jdk/internal/access/JavaLangAccess.java
>>  - Add DecimalDigitsTest to verify appendPair method with LATIN1 and UTF16 
>> encoding
>>  - Use DecimalDigits.appendPair for formatting in time classes
>>    
>>    This change modifies the toString() methods in MonthDay, YearMonth, 
>> ZoneOffset, and ChronoLocalDateImpl to use DecimalDigits.appendPair for 
>> formatting two-digit numbers. This provides a more efficient and consistent 
>> way to format these values.
>>    
>>    Also added a comment in ChronoLocalDateImpl.toString() to explain why 
>> get() is used instead of getLong() for performance reasons, as the values 
>> are guaranteed to be within the int range for all chronologies.
>>    
>>    Co-authored-by: Qwen-Coder <qwen-co...@alibabacloud.com>
>>  - Optimize year formatting in DateTimeHelper by reducing modulo operation
>>    
>>    Co-authored-by: Qwen-Coder <qwen-co...@alibabacloud.com>
>>    
>>    Refactored the year formatting logic to use subtraction instead of modulo 
>> for calculating the lower two digits, which can be slightly more efficient. 
>> Added a comment to clarify the safety of the input range for 
>> DecimalDigits.appendPair.
>>  - Refactor DateTimeHelper to use DecimalDigits.appendPair for date/time 
>> formatting\n\nThis change updates DateTimeHelper.formatTo methods for 
>> LocalDate and LocalTime\nto use the new DecimalDigits.appendPair method for 
>> formatting month, day, hour,\nminute, and second components. This improves 
>> code clarity and leverages the\nnewly introduced efficient two-digit integer 
>> appending functionality.
>>    
>>    Co-authored-by: Qwen-Coder <qwen-co...@alibabacloud.com>
>>  - Introduce appendPair method for efficient two-digit integer 
>> appending\n\nThis change adds a new internal API to efficiently append 
>> two-digit integers\n(00-99) to a StringBuilder. It includes:\n- 
>> AbstractStringBuilder.appendPair(int i): The core implementation.\n- 
>> JavaLangAccess.appendPair(StringBuilder, int): For internal access.\n- 
>> System.JavaLangAccessImpl.appendPair(StringBuilder, int): Bridge to 
>> AbstractStringBuilder.\n- DecimalDigits.appendPair(StringBuilder, int): 
>> Public static utility method.\n\nImproved Javadoc comments for clarity and 
>> consistency across all new methods.
>>    
>>    Co-authored-by: Qwen-Coder <qwen...
>
> src/java.base/share/classes/jdk/internal/util/DecimalDigits.java line 455:
> 
>> 453:      * If the value is between 0 and 9, it is formatted with a leading 
>> zero
>> 454:      * (e.g., 5 becomes "05"). If the value is outside the range 0-99,
>> 455:      * the behavior is unspecified.
> 
> Just out of interest, why leave the behaviour as unspecified instead of 
> validating and throwing an exception?

Just simply trust the caller

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

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

Reply via email to