diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2018-01-04 03:18:28 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-04 03:18:28 +0800 |
commit | c598a12af956a939587059f0f4753a0631b5b372 (patch) | |
tree | e45102c752f20296a579b3bc98d501d5d7fb0f26 /lib/compress.js | |
parent | cfe3a98ce50a1eb844654da57b4ef47a750feda5 (diff) | |
download | tracifyjs-c598a12af956a939587059f0f4753a0631b5b372.tar.gz tracifyjs-c598a12af956a939587059f0f4753a0631b5b372.zip |
apply `collapse_vars` to loop conditions (#2712)
Diffstat (limited to 'lib/compress.js')
-rw-r--r-- | lib/compress.js | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/compress.js b/lib/compress.js index fd59fb32..300bc61d 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; |