Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Amanieu d'Antras <amanieu@gmail.com>
  • Loading branch information
the8472 and Amanieu committed Aug 15, 2021
1 parent a98a309 commit 7256a6a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions library/std/src/time/monotonic.rs
Expand Up @@ -34,14 +34,14 @@ pub mod inner {
let packed = (secs << 32) | nanos;
let old = MONO.load(Relaxed);

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

0 comments on commit 7256a6a

Please sign in to comment.