Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changes/wrap-generate-context.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"tauri-codegen": "patch:perf"
---

Wrap the generated context code in a function to make rust analyzer faster
27 changes: 16 additions & 11 deletions crates/tauri-codegen/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -469,19 +469,24 @@ pub fn context_codegen(data: ContextData) -> EmbeddedAssetsResult<TokenStream> {
});

Ok(quote!({
let thread = ::std::thread::Builder::new()
.name(String::from("generated tauri context creation"))
.stack_size(8 * 1024 * 1024)
.spawn(|| #context)
.expect("unable to create thread with 8MiB stack");

match thread.join() {
Ok(context) => context,
Err(_) => {
eprintln!("the generated Tauri `Context` panicked during creation");
::std::process::exit(101);
// Wrapping in a function to make rust analyzer faster,
// see https://github.com/tauri-apps/tauri/pull/14457
fn inner<R: #root::Runtime>() -> #root::Context<R> {
let thread = ::std::thread::Builder::new()
.name(String::from("generated tauri context creation"))
.stack_size(8 * 1024 * 1024)
.spawn(|| #context)
.expect("unable to create thread with 8MiB stack");

match thread.join() {
Ok(context) => context,
Err(_) => {
eprintln!("the generated Tauri `Context` panicked during creation");
::std::process::exit(101);
}
}
}
inner()
}))
}

Expand Down
Loading