aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2018-01-15 16:42:31 +0800
committerGitHub <noreply@github.com>2018-01-15 16:42:31 +0800
commitb483678ca7f5e539cef9c57324ecc92d65800f7d (patch)
tree6e1909004e3767d2af175f964a4982bfe4ebc7cb
parentcbbe6fad60dd073c63575f591d631efa94bbceaf (diff)
downloadtracifyjs-b483678ca7f5e539cef9c57324ecc92d65800f7d.tar.gz
tracifyjs-b483678ca7f5e539cef9c57324ecc92d65800f7d.zip
avoid suboptimal termination in `passes` (#2787)
-rw-r--r--lib/compress.js15
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/compress.js b/lib/compress.js
index 7e3503fe..a461cb06 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -171,7 +171,8 @@ merge(Compressor.prototype, {
node.process_expression(true);
}
var passes = +this.options.passes || 1;
- var last_count = 1 / 0;
+ var min_count = 1 / 0;
+ var stopping = false;
var mangle = { ie8: this.option("ie8") };
for (var pass = 0; pass < passes; pass++) {
node.figure_out_scope(mangle);
@@ -183,9 +184,15 @@ merge(Compressor.prototype, {
node.walk(new TreeWalker(function() {
count++;
}));
- this.info("pass " + pass + ": last_count: " + last_count + ", count: " + count);
- if (count >= last_count) break;
- last_count = count;
+ this.info("pass " + pass + ": last_count: " + min_count + ", count: " + count);
+ if (count < min_count) {
+ min_count = count;
+ stopping = false;
+ } else if (stopping) {
+ break;
+ } else {
+ stopping = true;
+ }
}
}
if (this.option("expression")) {