aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2018-05-04 18:38:13 +0800
committerGitHub <noreply@github.com>2018-05-04 18:38:13 +0800
commitd835c72c80c25307de90f73748055afb523352bb (patch)
tree5ff28884cc066eadf4e3725f21190e49cc29c17e
parentc4cebb4b01e3d1dc75da50a9e3fb05d4d342407f (diff)
downloadtracifyjs-d835c72c80c25307de90f73748055afb523352bb.tar.gz
tracifyjs-d835c72c80c25307de90f73748055afb523352bb.zip
speed up `collapse_vars` (#3119)
-rw-r--r--lib/compress.js8
1 files changed, 3 insertions, 5 deletions
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++;