Commit ecb0cb661a

Andrew Kelley <andrew@ziglang.org>
2019-01-30 08:53:59
darwin time code: don't cast to int until the end
See #1648
1 parent 9ca94bb
Changed files (1)
std
std/os/time.zig
@@ -84,9 +84,9 @@ fn milliTimestampDarwin() u64 {
     var tv: darwin.timeval = undefined;
     var err = darwin.gettimeofday(&tv, null);
     debug.assert(err == 0);
-    const sec_ms = @intCast(u64, tv.tv_sec) * ms_per_s;
-    const usec_ms = @divFloor(@intCast(u64, tv.tv_usec), us_per_s / ms_per_s);
-    return u64(sec_ms) + u64(usec_ms);
+    const sec_ms = tv.tv_sec * ms_per_s;
+    const usec_ms = @divFloor(tv.tv_usec, us_per_s / ms_per_s);
+    return @intCast(u64, sec_ms + usec_ms);
 }
 
 fn milliTimestampPosix() u64 {