You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix quadratic time and space when parsing 'await/'
Pathalogical code can cause quick-lint-js to consume tons of memory and
tons of time. The root cause is infinite lookahead (implemented as backtracking) which occurs when parsing code like the following:
function f() {
await/
()=>{{{{{{{await/
()=>{{{{{{{await/
()=>{{{{{{{await/
()=>{{{{{{{await/
()=>{{{{{{{await/
}
quick-lint-js' algorithm for determining whether 'await' is supposed to
be an identifier or an operator parses what follows speculatively.
Because the speculative parse can parse an arbitrary amount of code,
and speculative parses can be nested, we end up with quadratic behavior.
Cache 'await' guesses to turn the quadratic behavior into linear
behavior.
This code should improve performance for pathalogical cases without
changing behavior.
0 commit comments