Skip to content

Commit 4e9809c

Browse files
authored
Clock::currentTime: Avoid calling unit.convert when the asked TimeUnit is MILLISECONDS (zio#8358)
1 parent cb3edd4 commit 4e9809c

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

core/shared/src/main/scala/zio/Clock.scala

+2-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ object Clock extends ClockPlatformSpecific with Serializable {
119119
inst.getEpochSecond * 1000000000 + inst.getNano
120120
case TimeUnit.MICROSECONDS =>
121121
inst.getEpochSecond * 1000000 + inst.getNano / 1000
122-
case _ => unit.convert(inst.toEpochMilli, TimeUnit.MILLISECONDS)
122+
case TimeUnit.MILLISECONDS => inst.toEpochMilli
123+
case _ => unit.convert(inst.toEpochMilli, TimeUnit.MILLISECONDS)
123124
}
124125
}
125126

0 commit comments

Comments
 (0)