Skip to content

Commit

Permalink
time: clean up redundant check in Wheel::poll() (#5574)
Browse files Browse the repository at this point in the history
The condition checked in the and_then() call is the same as is checked
in the match below, so we can clean it up by just matching on
next_expiration() directly.
  • Loading branch information
marcelo-gonzalez committed Mar 23, 2023
1 parent 768ede6 commit 1cb7bf1
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions tokio/src/runtime/time/wheel/mod.rs
Expand Up @@ -148,23 +148,13 @@ impl Wheel {
return Some(handle);
}

// under what circumstances is poll.expiration Some vs. None?
let expiration = self.next_expiration().and_then(|expiration| {
if expiration.deadline > now {
None
} else {
Some(expiration)
}
});

match expiration {
Some(ref expiration) if expiration.deadline > now => return None,
Some(ref expiration) => {
match self.next_expiration() {
Some(ref expiration) if expiration.deadline <= now => {
self.process_expiration(expiration);

self.set_elapsed(expiration.deadline);
}
None => {
_ => {
// in this case the poll did not indicate an expiration
// _and_ we were not able to find a next expiration in
// the current list of timers. advance to the poll's
Expand Down

0 comments on commit 1cb7bf1

Please sign in to comment.