diff options
author | alexlamsl <alexlamsl@gmail.com> | 2017-02-18 19:07:03 +0800 |
---|---|---|
committer | alexlamsl <alexlamsl@gmail.com> | 2017-02-21 13:29:57 +0800 |
commit | f584ca8d0766fb6d2a254dd4487afa91ed2c5034 (patch) | |
tree | ab4e021523e77f5d1a48369be5fe23b368244515 | |
parent | ae4db00991c6155fde42bd00c30614d922a4219a (diff) | |
download | tracifyjs-f584ca8d0766fb6d2a254dd4487afa91ed2c5034.tar.gz tracifyjs-f584ca8d0766fb6d2a254dd4487afa91ed2c5034.zip |
`-c sequences=N` suboptimal at N expression cutoff
N = 2:
a;
b;
c;
d;
was:
a, b;
c;
d;
now:
a, b;
c, d;
fixes #1455
closes #1457
-rw-r--r-- | lib/compress.js | 5 | ||||
-rw-r--r-- | test/compress/sequences.js | 44 |
2 files changed, 48 insertions, 1 deletions
diff --git a/lib/compress.js b/lib/compress.js index ee28ee14..e8b271f3 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -749,7 +749,10 @@ merge(Compressor.prototype, { seq = []; }; statements.forEach(function(stat){ - if (stat instanceof AST_SimpleStatement && seqLength(seq) < compressor.sequences_limit) { + if (stat instanceof AST_SimpleStatement) { + if (seqLength(seq) >= compressor.sequences_limit) { + push_seq(); + } seq.push(stat.body); } else { push_seq(); diff --git a/test/compress/sequences.js b/test/compress/sequences.js index 0e3319ab..8a3ffe89 100644 --- a/test/compress/sequences.js +++ b/test/compress/sequences.js @@ -169,3 +169,47 @@ for_sequences: { for (y = 5; false;); } } + +limit_1: { + options = { + sequences: 3, + }; + input: { + a; + b; + c; + d; + e; + f; + g; + h; + i; + j; + k; + } + expect: { + a, b, c; + d, e, f; + g, h, i; + j, k; + } +} + +limit_2: { + options = { + sequences: 3, + }; + input: { + a, b; + c, d; + e, f; + g, h; + i, j; + k; + } + expect: { + a, b, c, d; + e, f, g, h; + i, j, k; + } +} |