mirror of
https://github.com/tauri-apps/tauri.git
synced 2026-04-01 10:01:07 +02:00
perf(codegen): wrap generated context in a fn (#14457)
* perf(codegen): wrap generated context in a fn * Add comment about the reasoning
This commit is contained in:
5
.changes/wrap-generate-context.md
Normal file
5
.changes/wrap-generate-context.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"tauri-codegen": "patch:perf"
|
||||
---
|
||||
|
||||
Wrap the generated context code in a function to make rust analyzer faster
|
||||
@@ -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");
|
||||
// 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);
|
||||
match thread.join() {
|
||||
Ok(context) => context,
|
||||
Err(_) => {
|
||||
eprintln!("the generated Tauri `Context` panicked during creation");
|
||||
::std::process::exit(101);
|
||||
}
|
||||
}
|
||||
}
|
||||
inner()
|
||||
}))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user