Fix regression after e4c530240650535d1cb46569dfb013193471af05
authorMihai Bazon <mihai@bazon.net>
Wed, 30 Oct 2013 08:45:58 +0000 (10:45 +0200)
committerMihai Bazon <mihai@bazon.net>
Wed, 30 Oct 2013 08:45:58 +0000 (10:45 +0200)
`x * (y * z)` ==> `x * y * z` -- the better place to do this is in the
compressor rather than codegen.

lib/compress.js

index 813561c..0bbd24e 100644 (file)
@@ -2089,6 +2089,19 @@ merge(Compressor.prototype, {
                 }
             }
         }
+        // x * (y * z)  ==>  x * y * z
+        if (self.right instanceof AST_Binary
+            && self.right.operator == self.operator
+            && (self.operator == "*" || self.operator == "&&" || self.operator == "||"))
+        {
+            self.left = make_node(AST_Binary, self.left, {
+                operator : self.operator,
+                left     : self.left,
+                right    : self.right.left
+            });
+            self.right = self.right.right;
+            return self.transform(compressor);
+        }
         return self.evaluate(compressor)[0];
     });