aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authoralexlamsl <alexlamsl@gmail.com>2017-02-18 19:07:52 +0800
committeralexlamsl <alexlamsl@gmail.com>2017-02-21 13:29:57 +0800
commit6b3c49e45837e8e1b32b60fe3b217b965ac16efd (patch)
tree3e95051778ccaf07859353ef38a1bad53d35f814 /lib
parentf584ca8d0766fb6d2a254dd4487afa91ed2c5034 (diff)
downloadtracifyjs-6b3c49e45837e8e1b32b60fe3b217b965ac16efd.tar.gz
tracifyjs-6b3c49e45837e8e1b32b60fe3b217b965ac16efd.zip
improve string concatenation
shuffle associative operations to minimise parentheses and aid other uglification efforts closes #1454
Diffstat (limited to 'lib')
-rw-r--r--lib/compress.js9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/compress.js b/lib/compress.js
index e8b271f3..536b7518 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -2751,9 +2751,16 @@ merge(Compressor.prototype, {
}
// x && (y && z) ==> x && y && z
// x || (y || z) ==> x || y || z
+ // x + ("y" + z) ==> x + "y" + z
+ // "x" + (y + "z")==> "x" + y + "z"
if (self.right instanceof AST_Binary
&& self.right.operator == self.operator
- && (self.operator == "&&" || self.operator == "||"))
+ && (self.operator == "&&"
+ || self.operator == "||"
+ || (self.operator == "+"
+ && (self.right.left.is_string(compressor)
+ || (self.left.is_string(compressor)
+ && self.right.right.is_string(compressor))))))
{
self.left = make_node(AST_Binary, self.left, {
operator : self.operator,