From 5e6ee59ecd255c1d25bb0f687240183b63c4887d Mon Sep 17 00:00:00 2001 From: Ulf Lilleengen Date: Wed, 20 Oct 2021 14:25:34 +0200 Subject: [PATCH] Fix time calculation Use unwrap_or_get to avoid checking time when not necessary --- embassy/src/time/driver_std.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/embassy/src/time/driver_std.rs b/embassy/src/time/driver_std.rs index a571d5214..0b5c6f85c 100644 --- a/embassy/src/time/driver_std.rs +++ b/embassy/src/time/driver_std.rs @@ -90,7 +90,7 @@ impl TimeDriver { // Ensure we don't overflow let until = zero .checked_add(StdDuration::from_micros(next_alarm)) - .unwrap_or(zero + StdDuration::from_secs(1)); + .unwrap_or_else(|| StdInstant::now() + StdDuration::from_secs(1)); unsafe { DRIVER.signaler.as_ref() }.wait_until(until); }