From ffccb233e5338fd99cdcda17058ffb0d3415cfcb Mon Sep 17 00:00:00 2001 From: Mihai Bazon Date: Mon, 5 Nov 2012 16:01:20 +0200 Subject: [PATCH] convert `while` into `for` --- lib/compress.js | 9 +++++++++ 1 file changed, 9 insertions(+) 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) { -- 2.34.1