Skip to content

Commit 1f6f644

Browse files
perf(javascript): keep collapse_vars' state in one object per nesting depth
terser's `collapse` keeps its scan in function-scoped `var`s that its closures share across candidates, and `collapseFrom` built those 25 closures, two transformers, a walker per candidate and a transformer per fold on every call: 37,201 calls and 86 MB per minify of typescript.js. The state now lives in a `CollapseState` held per nesting depth, the helpers are module-level functions handed it, and the scanners, the left-value walker, the remover and the left-value map are built once per state.
1 parent ab4d0e6 commit 1f6f644

2 files changed

Lines changed: 1061 additions & 853 deletions

File tree

0 commit comments

Comments
 (0)