Skip to content

Commit

Permalink
improve performance when handling unused variables in collapse_vars (
Browse files Browse the repository at this point in the history
  • Loading branch information
alexlamsl authored Apr 15, 2018
1 parent eaa2c1f commit 7362f57
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/compress.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 7362f57

Please sign in to comment.