perf: skip quadratic blocker analysis when no top-level await (#18548)

Skip function reference tracing in `calculate_blockers` when a component
has no top-level `await`.

Blockers only represent dependencies on top-level async statements.
Without a top-level `await`, no binding can have a blocker, so tracing
every top-level function cannot affect the generated output. In large
components with many functions and transitive assignments, that
unnecessary work can become quadratic.
pull/18552/head
Joe Schafer 1 month ago committed by GitHub
parent 22e0adb75a
commit d0dbe1a480
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
'svelte': patch
---
perf: skip unnecessary blocker analysis when compiling components without top-level await

@ -1221,6 +1221,10 @@ function calculate_blockers(instance, analysis) {
} }
} }
// With no top-level await, no binding can have a blocker and function tracing
// cannot affect the output.
if (!awaited) return;
flush_sync_group(); flush_sync_group();
for (const fn of functions) { for (const fn of functions) {

Loading…
Cancel
Save