RFR: 8310241: OffsetDateTime compareTo redundant computation

Roger Riggs rriggs at openjdk.org
Wed Jun 28 17:46:53 UTC 2023


On Thu, 22 Jun 2023 19:03:03 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

Reopening this to propose a different implementation and to 
provide the test of the specific condition that is missing from java/time/jck/java/time/TCKOffsetDateTime.java

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

PR Comment: https://git.openjdk.org/jdk/pull/14618#issuecomment-1611829783


More information about the core-libs-dev mailing list