diff options
author | Mihai Bazon <mihai@bazon.net> | 2012-09-14 15:36:38 +0300 |
---|---|---|
committer | Mihai Bazon <mihai@bazon.net> | 2012-09-14 15:36:38 +0300 |
commit | 924aa580602a4ad94f1079dcd157286314066553 (patch) | |
tree | acd65dd576ded856e5e7cc3b15ee473539b645ac /lib/output.js | |
parent | 93b973c99dd25aeff66ff31f2881e9ce252eaac6 (diff) | |
download | tracifyjs-924aa580602a4ad94f1079dcd157286314066553.tar.gz tracifyjs-924aa580602a4ad94f1079dcd157286314066553.zip |
more optimizations that v1 does and some cleanups
- a = a + x ==> a+=x
- joining consecutive var statements (hoisting is not always desirable)
- x == false ==> x == 0, x != true ==> x != 1
- x, x ==> x; x = exp(), x ==> x = exp()
- discarding useless break-s
Diffstat (limited to 'lib/output.js')
-rw-r--r-- | lib/output.js | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/output.js b/lib/output.js index f7cb47c6..a93f7387 100644 --- a/lib/output.js +++ b/lib/output.js @@ -779,9 +779,11 @@ function OutputStream(options) { AST_Call.prototype.print.call(self, output); }); DEFPRINT(AST_Seq, function(self, output){ - self.first.print(output); - output.comma(); - self.second.print(output); + self.car.print(output); + if (self.cdr) { + output.comma(); + self.cdr.print(output); + } }); DEFPRINT(AST_Dot, function(self, output){ var expr = self.expression; @@ -921,13 +923,12 @@ function OutputStream(options) { while (i > 0) { if (p instanceof AST_Statement && p.body === node) return true; - if ((p instanceof AST_Seq && p.first === node ) || + if ((p instanceof AST_Seq && p.car === node ) || (p instanceof AST_Call && p.expression === node ) || (p instanceof AST_Dot && p.expression === node ) || (p instanceof AST_Sub && p.expression === node ) || (p instanceof AST_Conditional && p.condition === node ) || - (p instanceof AST_Binary && p.first === node ) || - (p instanceof AST_Assign && p.first === node ) || + (p instanceof AST_Binary && p.left === node ) || (p instanceof AST_UnaryPostfix && p.expression === node )) { node = p; |