diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2018-04-15 12:38:31 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-15 12:38:31 +0800 |
commit | 7362f579666194aed000005c956f2e0e83c9a87d (patch) | |
tree | 21f618b15e13232bca4da008039f05f7e5b06c9b /lib | |
parent | eaa2c1f6af10e08c9ece097bfb8c1f15a74ffa28 (diff) | |
download | tracifyjs-7362f579666194aed000005c956f2e0e83c9a87d.tar.gz tracifyjs-7362f579666194aed000005c956f2e0e83c9a87d.zip |
improve performance when handling unused variables in `collapse_vars` (#3084)
fixes #3082
Diffstat (limited to 'lib')
-rw-r--r-- | lib/compress.js | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/compress.js b/lib/compress.js index 999e03c4..f82d99ef 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -1348,8 +1348,9 @@ merge(Compressor.prototype, { if (expr instanceof AST_VarDef) { var def = expr.name.definition(); if (!member(expr.name, def.orig)) return; - var declared = def.orig.length - def.eliminated; var referenced = def.references.length - def.replaced; + if (!referenced) return; + var declared = def.orig.length - def.eliminated; if (declared > 1 && !(expr.name instanceof AST_SymbolFunarg) || (referenced > 1 ? mangleable_var(expr) : !compressor.exposed(def))) { return make_node(AST_SymbolRef, expr.name, expr.name); |