Skip to content

Commit 7256a6a

Browse files
the8472Amanieu
andauthored
Apply suggestions from code review
Co-authored-by: Amanieu d'Antras <[email protected]>
1 parent a98a309 commit 7256a6a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

library/std/src/time/monotonic.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@ pub mod inner {
3434
let packed = (secs << 32) | nanos;
3535
let old = MONO.load(Relaxed);
3636

37-
if packed == UNINITIALIZED || packed.wrapping_sub(old) < u64::MAX / 2 {
37+
if old == UNINITIALIZED || packed.wrapping_sub(old) < u64::MAX / 2 {
3838
MONO.store(packed, Relaxed);
3939
raw
4040
} else {
4141
// Backslide occurred. We reconstruct monotonized time by assuming the clock will never
4242
// backslide more than 2`32 seconds which means we can reuse the upper 32bits from
4343
// the seconds.
44-
let secs = (secs & 0xffff_ffff << 32) | old >> 32;
44+
let secs = (secs & 0xffff_ffff_0000_0000) | old >> 32;
4545
let nanos = old as u32;
4646
ZERO.checked_add_duration(&Duration::new(secs, nanos)).unwrap()
4747
}

0 commit comments

Comments
 (0)