aboutsummaryrefslogtreecommitdiff
path: root/lib/compress.js
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2018-02-12 23:28:28 +0800
committerGitHub <noreply@github.com>2018-02-12 23:28:28 +0800
commit0809699bdc7b1c249c7bbe02924a4a861aff8bea (patch)
treecf442345213f3c85a659ae84db6f82575c3ba2e8 /lib/compress.js
parent2088e1c19d97955b5582e08396fca8c7b7dadd83 (diff)
downloadtracifyjs-0809699bdc7b1c249c7bbe02924a4a861aff8bea.tar.gz
tracifyjs-0809699bdc7b1c249c7bbe02924a4a861aff8bea.zip
simplify `do-while` into `for` (#2907)
fixes #2904
Diffstat (limited to 'lib/compress.js')
-rw-r--r--lib/compress.js7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/compress.js b/lib/compress.js
index 282ab780..2b796dcc 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -3672,6 +3672,13 @@ merge(Compressor.prototype, {
]
}).optimize(compressor);
}
+ if (self.body instanceof AST_SimpleStatement) return make_node(AST_For, self, {
+ condition: make_sequence(self.condition, [
+ self.body.body,
+ self.condition
+ ]),
+ body: make_node(AST_EmptyStatement, self)
+ }).optimize(compressor);
return self;
});