From e2216e30ca9d685e13a4e0f71d8309541a349126 Mon Sep 17 00:00:00 2001 From: Christian Meissl Date: Fri, 17 May 2024 21:09:09 +0200 Subject: [PATCH] timers: optimize for timeout extension pattern it is more likely an older timeout gets canceled and replaced. reversing the search might yield some performance improvement in this case --- src/sources/timer.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/sources/timer.rs b/src/sources/timer.rs index 2b164dc3..09ebba09 100644 --- a/src/sources/timer.rs +++ b/src/sources/timer.rs @@ -241,6 +241,7 @@ impl TimerWheel { self.heap .iter() + .rev() .find(|data| data.counter == counter) .map(|data| data.token.take()); }