aboutsummaryrefslogtreecommitdiff
path: root/lib/compress.js
diff options
context:
space:
mode:
authorMihai Bazon <mihai@bazon.net>2012-11-05 16:01:20 +0200
committerMihai Bazon <mihai@bazon.net>2012-11-05 16:01:20 +0200
commitffccb233e5338fd99cdcda17058ffb0d3415cfcb (patch)
treedde036d622afa2e7d6f9eb64a34a01a7d496bc95 /lib/compress.js
parentfba0c1aafe5e54a982238bd7e54596852617ef6c (diff)
downloadtracifyjs-ffccb233e5338fd99cdcda17058ffb0d3415cfcb.tar.gz
tracifyjs-ffccb233e5338fd99cdcda17058ffb0d3415cfcb.zip
convert `while` into `for`
Diffstat (limited to 'lib/compress.js')
-rw-r--r--lib/compress.js9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/compress.js b/lib/compress.js
index a7a6172b..59c9128d 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -1118,6 +1118,15 @@ merge(Compressor.prototype, {
return self;
});
+ OPT(AST_While, function(self, compressor) {
+ if (!compressor.option("loops")) return self;
+ self = AST_DWLoop.prototype.optimize.call(self, compressor);
+ if (self instanceof AST_While) {
+ self = make_node(AST_For, self, self);
+ }
+ return self;
+ });
+
OPT(AST_For, function(self, compressor){
var cond = self.condition;
if (cond) {