gpui: Reduce amount of monomorphizations taking place (#48014)

Re-lands #3266 after recent scheduler changes

Back-of-napkin calculation: editor tests (build) went from 32s to 17s.

Release Notes:

- N/A
This commit is contained in:
Piotr Osiewicz authored and GitHub committed 2026-02-02 17:18:32 +01:00
1 parent d2d0e11cf9
commit 8e06fcc99a
3 files changed
+28 -23

No files matched your search

+23 -19
View File
@@ -1462,29 +1462,33 @@ impl App {
cx.window_update_stack.push(window.handle.id);
let result = update(root_view, &mut window, cx);
cx.window_update_stack.pop();
fn trail(id: WindowId, window: Box<Window>, cx: &mut App) -> Option<()> {
cx.window_update_stack.pop();
if window.removed {
cx.window_handles.remove(&id);
cx.windows.remove(id);
if window.removed {
cx.window_handles.remove(&id);
cx.windows.remove(id);
cx.window_closed_observers.clone().retain(&(), |callback| {
callback(cx);
true
});
cx.window_closed_observers.clone().retain(&(), |callback| {
callback(cx);
true
});
let quit_on_empty = match cx.quit_mode {
QuitMode::Explicit => false,
QuitMode::LastWindowClosed => true,
QuitMode::Default => cfg!(not(target_os = "macos")),
};
let quit_on_empty = match cx.quit_mode {
QuitMode::Explicit => false,
QuitMode::LastWindowClosed => true,
QuitMode::Default => cfg!(not(target_os = "macos")),
};
if quit_on_empty && cx.windows.is_empty() {
cx.quit();
if quit_on_empty && cx.windows.is_empty() {
cx.quit();
}
} else {
cx.windows.get_mut(id)?.replace(window);
}
} else {
cx.windows.get_mut(id)?.replace(window);
Some(())
}
trail(id, window, cx)?;
Some(result)
})
@@ -1529,7 +1533,7 @@ impl App {
let mut cx = self.to_async();
self.foreground_executor
.spawn(async move { f(&mut cx).await })
.spawn(async move { f(&mut cx).await }.boxed_local())
}
/// Spawns the future returned by the given function on the main thread with
@@ -1547,7 +1551,7 @@ impl App {
let mut cx = self.to_async();
self.foreground_executor
.spawn_with_priority(priority, async move { f(&mut cx).await })
.spawn_with_priority(priority, async move { f(&mut cx).await }.boxed_local())
}
/// Schedules the given function to be run at the end of the current effect cycle, allowing entities
+3 -2
View File
@@ -7,6 +7,7 @@ use crate::{
use anyhow::Context as _;
use derive_more::{Deref, DerefMut};
use futures::channel::oneshot;
use smol::future::FutureExt;
use std::{future::Future, rc::Weak};
use super::{Context, WeakEntity};
@@ -184,7 +185,7 @@ impl AsyncApp {
{
let mut cx = self.clone();
self.foreground_executor
.spawn(async move { f(&mut cx).await })
.spawn(async move { f(&mut cx).await }.boxed_local())
}
/// Determine whether global state of the specified type has been assigned.
@@ -322,7 +323,7 @@ impl AsyncWindowContext {
{
let mut cx = self.clone();
self.foreground_executor
.spawn(async move { f(&mut cx).await })
.spawn(async move { f(&mut cx).await }.boxed_local())
}
/// Present a platform dialog.
+2 -2
View File
@@ -145,7 +145,7 @@ impl BackgroundExecutor {
where
R: Send + 'static,
{
self.spawn_with_priority(Priority::default(), future)
self.spawn_with_priority(Priority::default(), future.boxed())
}
/// Enqueues the given future to be run to completion on a background thread with the given priority.
@@ -409,7 +409,7 @@ impl ForegroundExecutor {
where
R: 'static,
{
Task::from_scheduler(self.inner.spawn(future))
Task::from_scheduler(self.inner.spawn(future.boxed_local()))
}
/// Enqueues the given Task to run on the main thread with the given priority.