aboutsummaryrefslogtreecommitdiff
path: root/lib/compress.js
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2017-07-13 02:18:59 +0800
committerGitHub <noreply@github.com>2017-07-13 02:18:59 +0800
commit458e3e15f0f315dcd4a99b02bed0fb740ffdfc17 (patch)
tree133c68c470f9507ef041a86d336ef041fad396d0 /lib/compress.js
parentc615a1e80aa0960fa7eb888e1bc085e70d3c7bfe (diff)
downloadtracifyjs-458e3e15f0f315dcd4a99b02bed0fb740ffdfc17.tar.gz
tracifyjs-458e3e15f0f315dcd4a99b02bed0fb740ffdfc17.zip
enhance `passes` (#2229)
- remove hardcoded upper limit - continue based on node count reduction - emit verbose statistics fixes #2226
Diffstat (limited to 'lib/compress.js')
-rw-r--r--lib/compress.js12
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/compress.js b/lib/compress.js
index 74fb62ec..9b79a3cb 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -148,10 +148,20 @@ merge(Compressor.prototype, {
node.process_expression(true);
}
var passes = +this.options.passes || 1;
- for (var pass = 0; pass < passes && pass < 3; ++pass) {
+ var last_count = 1 / 0;
+ for (var pass = 0; pass < passes; pass++) {
if (pass > 0 || this.option("reduce_vars"))
node.reset_opt_flags(this, true);
node = node.transform(this);
+ if (passes > 1) {
+ var count = 0;
+ node.walk(new TreeWalker(function() {
+ count++;
+ }));
+ this.info("pass " + pass + ": last_count: " + last_count + ", count: " + count);
+ if (count >= last_count) break;
+ last_count = count;
+ }
}
if (this.option("expression")) {
node.process_expression(false);