Skip to content

Commit fc89566

Browse files
committed
Avoid 128-bit arithmetic where possible
1 parent 99f5136 commit fc89566

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/libcore/time.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ impl Duration {
277277
#[unstable(feature = "duration_as_u128", issue = "50202")]
278278
#[inline]
279279
pub fn as_millis(&self) -> u128 {
280-
self.secs as u128 * MILLIS_PER_SEC as u128 + self.nanos as u128 / NANOS_PER_MILLI as u128
280+
self.secs as u128 * MILLIS_PER_SEC as u128 + (self.nanos / NANOS_PER_MILLI) as u128
281281
}
282282

283283
/// Returns the total number of microseconds contained by this `Duration`.
@@ -294,7 +294,7 @@ impl Duration {
294294
#[unstable(feature = "duration_as_u128", issue = "50202")]
295295
#[inline]
296296
pub fn as_micros(&self) -> u128 {
297-
self.secs as u128 * MICROS_PER_SEC as u128 + self.nanos as u128 / NANOS_PER_MICRO as u128
297+
self.secs as u128 * MICROS_PER_SEC as u128 + (self.nanos / NANOS_PER_MICRO) as u128
298298
}
299299

300300
/// Returns the total number of nanoseconds contained by this `Duration`.

0 commit comments

Comments
 (0)