diff options
author | alexlamsl <alexlamsl@gmail.com> | 2017-02-18 19:05:54 +0800 |
---|---|---|
committer | alexlamsl <alexlamsl@gmail.com> | 2017-02-21 13:29:57 +0800 |
commit | ae4db00991c6155fde42bd00c30614d922a4219a (patch) | |
tree | 685db4fa2dcb7e157c7a4afea5097c5236806bc5 /lib | |
parent | 100307ab31e89075a5b0e56d47597a0525dd43a6 (diff) | |
download | tracifyjs-ae4db00991c6155fde42bd00c30614d922a4219a.tar.gz tracifyjs-ae4db00991c6155fde42bd00c30614d922a4219a.zip |
tweak do-while loops
- `do{...}while(false)` => `{...}`
- clean up `AST_While` logic
closes #1452
Diffstat (limited to 'lib')
-rw-r--r-- | lib/compress.js | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/lib/compress.js b/lib/compress.js index 2ba2982e..ee28ee14 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -1813,8 +1813,14 @@ merge(Compressor.prototype, { extract_declarations_from_unreachable_code(compressor, self.body, a); return make_node(AST_BlockStatement, self, { body: a }); } + } else { + // self instanceof AST_Do + return self.body; } } + if (self instanceof AST_While) { + return make_node(AST_For, self, self).transform(compressor); + } return self; }); @@ -1863,16 +1869,6 @@ merge(Compressor.prototype, { } }; - 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) { - if_break_in_loop(self, compressor); - self = make_node(AST_For, self, self).transform(compressor); - } - return self; - }); - OPT(AST_For, function(self, compressor){ var cond = self.condition; if (cond) { |