diff options
author | alexlamsl <alexlamsl@gmail.com> | 2017-02-18 19:07:52 +0800 |
---|---|---|
committer | alexlamsl <alexlamsl@gmail.com> | 2017-02-21 13:29:57 +0800 |
commit | 6b3c49e45837e8e1b32b60fe3b217b965ac16efd (patch) | |
tree | 3e95051778ccaf07859353ef38a1bad53d35f814 /lib | |
parent | f584ca8d0766fb6d2a254dd4487afa91ed2c5034 (diff) | |
download | tracifyjs-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.js | 9 |
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, |