[Pkg-javascript-commits] [uglifyjs] 389/491: apply `collapse_vars` to loop conditions (#2712)

Jonas Smedegaard dr at jones.dk
Wed Feb 14 19:51:55 UTC 2018


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

js pushed a commit to annotated tag debian/3.3.10-1
in repository uglifyjs.

commit c598a12af956a939587059f0f4753a0631b5b372
Author: Alex Lam S.L <alexlamsl at gmail.com>
Date:   Thu Jan 4 03:18:28 2018 +0800

    apply `collapse_vars` to loop conditions (#2712)
---
 lib/compress.js            | 5 +++++
 test/compress/functions.js | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/lib/compress.js b/lib/compress.js
index fd59fb3..300bc61 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -1171,10 +1171,14 @@ merge(Compressor.prototype, {
                     extract_candidates(expr.alternative);
                 } else if (expr instanceof AST_Definitions) {
                     expr.definitions.forEach(extract_candidates);
+                } else if (expr instanceof AST_DWLoop) {
+                    extract_candidates(expr.condition);
                 } else if (expr instanceof AST_Exit) {
                     if (expr.value) extract_candidates(expr.value);
                 } else if (expr instanceof AST_For) {
                     if (expr.init) extract_candidates(expr.init);
+                    if (expr.condition) extract_candidates(expr.condition);
+                    if (expr.step) extract_candidates(expr.step);
                 } else if (expr instanceof AST_If) {
                     extract_candidates(expr.condition);
                 } else if (expr instanceof AST_Sequence) {
@@ -1205,6 +1209,7 @@ merge(Compressor.prototype, {
                 if (parent instanceof AST_Conditional) return node;
                 if (parent instanceof AST_Exit) return node;
                 if (parent instanceof AST_If) return node;
+                if (parent instanceof AST_IterationStatement) return node;
                 if (parent instanceof AST_Sequence) return find_stop(parent, level + 1);
                 if (parent instanceof AST_Switch) return node;
                 if (parent instanceof AST_VarDef) return node;
diff --git a/test/compress/functions.js b/test/compress/functions.js
index f38977b..b6b6898 100644
--- a/test/compress/functions.js
+++ b/test/compress/functions.js
@@ -1416,7 +1416,7 @@ issue_2630_5: {
         !function() {
             do {
                 c *= 10;
-            } while (c += 3, (c = 2 + c) < 100);
+            } while ((c = 2 + (c += 3)) < 100);
         }();
         console.log(c);
     }

-- 
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