[Pkg-javascript-commits] [uglifyjs] 21/228: `-c sequences=N` suboptimal at N expression cutoff

Jonas Smedegaard dr at jones.dk
Sat Apr 15 14:25:13 UTC 2017


This is an automated email from the git hooks/post-receive script.

js pushed a commit to branch master
in repository uglifyjs.

commit f584ca8d0766fb6d2a254dd4487afa91ed2c5034
Author: alexlamsl <alexlamsl at gmail.com>
Date:   Sat Feb 18 19:07:03 2017 +0800

    `-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
---
 lib/compress.js            |  5 ++++-
 test/compress/sequences.js | 44 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 48 insertions(+), 1 deletion(-)

diff --git a/lib/compress.js b/lib/compress.js
index ee28ee1..e8b271f 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 0e3319a..8a3ffe8 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;
+    }
+}

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/uglifyjs.git



More information about the Pkg-javascript-commits mailing list