From: Alex Lam S.L Date: Fri, 4 May 2018 10:38:13 +0000 (+0800) Subject: speed up `collapse_vars` (#3119) X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=d835c72c80c25307de90f73748055afb523352bb;p=UglifyJS.git speed up `collapse_vars` (#3119) --- diff --git a/lib/compress.js b/lib/compress.js index fec4b951..31747c92 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -1062,9 +1062,11 @@ merge(Compressor.prototype, { if (is_lhs(node, parent)) { if (value_def) replaced++; return node; + } else { + replaced++; + if (value_def && candidate instanceof AST_VarDef) return node; } CHANGED = abort = true; - replaced++; compressor.info("Collapsing {name} [{file}:{line},{col}]", { name: node.print_to_string(), file: node.start.file, @@ -1075,10 +1077,6 @@ merge(Compressor.prototype, { return make_node(AST_UnaryPrefix, candidate, candidate); } if (candidate instanceof AST_VarDef) { - if (value_def) { - abort = false; - return node; - } var def = candidate.name.definition(); if (def.references.length - def.replaced == 1 && !compressor.exposed(def)) { def.replaced++;