diff --git a/.changes/dynamic-dispatch-async-commands.md b/.changes/dynamic-dispatch-async-commands.md new file mode 100644 index 000000000000..3af90a42f116 --- /dev/null +++ b/.changes/dynamic-dispatch-async-commands.md @@ -0,0 +1,5 @@ +--- +tauri: "patch:perf" +--- + +Use dynamic dispatch for async commands in dev, this should speed up the compilation time by quite a bit, and significantly reduces the incremental compilation time diff --git a/crates/tauri/src/ipc/mod.rs b/crates/tauri/src/ipc/mod.rs index ce8d579e2188..904d6ebba8a2 100644 --- a/crates/tauri/src/ipc/mod.rs +++ b/crates/tauri/src/ipc/mod.rs @@ -339,6 +339,34 @@ impl InvokeResolver { /// Reply to the invoke promise with an async task which is already serialized. pub fn respond_async_serialized(self, task: F) + where + F: Future> + Send + 'static, + { + // Dynamic dispatch the call in dev for a faster compile time + // TODO: Revisit this and see if we can do this for the release build as well if the performace hit is not a problem + #[cfg(debug_assertions)] + { + self.respond_async_serialized_dyn(Box::pin(task)) + } + #[cfg(not(debug_assertions))] + { + self.respond_async_serialized_inner(task) + } + } + + /// Dynamic dispatch the [`Self::respond_async_serialized`] call + #[cfg(debug_assertions)] + fn respond_async_serialized_dyn( + self, + task: std::pin::Pin< + Box> + Send + 'static>, + >, + ) { + self.respond_async_serialized_inner(task) + } + + /// Reply to the invoke promise with an async task which is already serialized. + fn respond_async_serialized_inner(self, task: F) where F: Future> + Send + 'static, {