Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Skip spawning task for `background_executor.timer(Duration::ZERO)` (#21729)
Michael Sloan16ecbafa7a28
diff --git a/crates/gpui/src/executor.rs b/crates/gpui/src/executor.rsindex 3035892d7a1..34132d72f84 100644--- a/crates/gpui/src/executor.rs+++ b/crates/gpui/src/executor.rs@@ -328,6 +328,9 @@ impl BackgroundExecutor {/// Depending on other concurrent tasks the elapsed duration may be longer/// than requested.pub fn timer(&self, duration: Duration) -> Task<()> {+ if duration.is_zero() {+ return Task::ready(());+ }let (runnable, task) = async_task::spawn(async move {}, {let dispatcher = self.dispatcher.clone();move |runnable| dispatcher.dispatch_after(duration, runnable)