From: Dan Wolff Date: Sun, 11 Nov 2012 13:53:34 +0000 (+0200) Subject: convert x.toString() to ""+x instead of x+"" X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=b49230ab8d717d91710d8c383c79ded77c78a39e;p=UglifyJS.git convert x.toString() to ""+x instead of x+"" In some places this can save one byte in whitespace, e.g. after return. Example: function f(arg) { // return""+arg - no space between return and "" return arg.toString(); } --- diff --git a/lib/compress.js b/lib/compress.js index 469ee6e2..9400b864 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -1413,9 +1413,9 @@ merge(Compressor.prototype, { } else if (exp instanceof AST_Dot && exp.property == "toString" && self.args.length == 0) { return make_node(AST_Binary, self, { - left: exp.expression, + left: make_node(AST_String, self, { value: "" }), operator: "+", - right: make_node(AST_String, self, { value: "" }) + right: exp.expression }).transform(compressor); } }