From 255911f2e94c3bce7b166950a843ff8a2774ba7b Mon Sep 17 00:00:00 2001 From: Max Inden Date: Fri, 29 Mar 2024 15:23:30 +0100 Subject: [PATCH] Fix last_bucket calc --- neqo-common/src/timer.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/neqo-common/src/timer.rs b/neqo-common/src/timer.rs index d490e7c0e5..7f70da1924 100644 --- a/neqo-common/src/timer.rs +++ b/neqo-common/src/timer.rs @@ -198,13 +198,13 @@ impl Timer { /// /// Impossible, I think. pub fn take_next(&mut self, until: Instant) -> Option { - let delta = self.delta(until); - let range = if self.cursor < delta { + let last_bucket = (self.cursor + self.delta(until)) % self.items.len(); + let range = if self.cursor < last_bucket { #[allow(clippy::range_plus_one)] // non-inclusive range to match with type below - (self.cursor..(self.cursor + delta + 1)).chain(0..0) // additional empty range to match - // with type below + (self.cursor..(last_bucket + 1)).chain(0..0) // additional empty range to match with + // type below } else { - (self.cursor..self.items.len()).chain(0..delta) + (self.cursor..self.items.len()).chain(0..last_bucket) }; for i in range {