RFR: 8310232: java.time.Clock$TickClock.millis() fails in runtime when tick is 1 microsecond [v2]
Naoto Sato
naoto at openjdk.org
Wed Jun 28 16:58:57 UTC 2023
On Wed, 28 Jun 2023 14:12:53 GMT, Roger Riggs <rriggs at openjdk.org> wrote:
>> src/java.base/share/classes/java/time/Clock.java line 762:
>>
>>> 760: public long millis() {
>>> 761: long millis = baseClock.millis();
>>> 762: return tickNanos < 1000_000L ? millis : millis - Math.floorMod(millis, tickNanos / 1000_000L);
>>
>> Cleaner precedence:
>>
>> Suggestion:
>>
>> long trunc = (tickNanos >= 1000_000L) ? Math.floorMod(millis, tickNanos / 1000_000L) : 0;
>> return millis - trunc;
>
> Either is fine, the current version avoids any extra operations if no (further) truncation is needed.
Thanks. I think it is OK as it is.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/14657#discussion_r1245509389
More information about the core-libs-dev
mailing list