RFR: 8310241: OffsetDateTime compareTo redundant computation [v2]
Naoto Sato
naoto at openjdk.org
Wed Jun 28 20:23:01 UTC 2023
On Wed, 28 Jun 2023 17:46:51 GMT, Roger Riggs <rriggs at openjdk.org> wrote:
>> Remove a redundant comparison in java.time `OffsetDateTime.compareTo()`.
>> If the `compareInstant` utility method returns 0 (equal), it compares the `LocalDateTime`.
>> However, `compareInstant` has already done that comparison; if it found equal, the `compareTo` method unnecessarily does it again.
>> The code is refactored in `compareTo` to do the comparison of `LocalDateTime` exactly once, if it is needed.
>>
>> This case is NOT covered by an existing test in test/jdk/java/time/tck/java/time/TCKOffsetDateTime.java
>
> Roger Riggs has updated the pull request incrementally with one additional commit since the last revision:
>
> Reopen to work on an improved fix
> Add a test for the specific condition being optimized, the test was missing in the original.
LGTM
-------------
Marked as reviewed by naoto (Reviewer).
PR Review: https://git.openjdk.org/jdk/pull/14618#pullrequestreview-1503926085
More information about the core-libs-dev
mailing list