Add simple optimization for empty-string concats.
authorRichard van Velzen <rvanvelzen@expert-shops.com>
Mon, 12 Nov 2012 14:41:03 +0000 (15:41 +0100)
committerRichard van Velzen <rvanvelzen@expert-shops.com>
Mon, 12 Nov 2012 14:41:03 +0000 (15:41 +0100)
ref. #43

lib/compress.js

index a4a53f5..fce0757 100644 (file)
@@ -1642,6 +1642,11 @@ merge(Compressor.prototype, {
               case "<=": reverse(">="); break;
             }
         }
+        if (self.operator == "+" && self.right instanceof AST_String
+            && self.right.getValue() === "" && self.left instanceof AST_Binary
+            && self.left.operator == "+" && self.left.left instanceof AST_String) {
+            return self.left;
+        }
         return self;
     });