@@ -3106,7 +3106,12 @@ merge(Compressor.prototype, {
|
||||
(function(def) {
|
||||
def(AST_Node, return_false);
|
||||
def(AST_Assign, function(compressor) {
|
||||
return (this.operator == "=" || this.operator == "+=") && this.right.is_string(compressor);
|
||||
switch (this.operator) {
|
||||
case "+=":
|
||||
if (this.left.is_string(compressor)) return true;
|
||||
case "=":
|
||||
return this.right.is_string(compressor);
|
||||
}
|
||||
});
|
||||
def(AST_Binary, function(compressor) {
|
||||
return this.operator == "+" &&
|
||||
@@ -7365,10 +7370,9 @@ merge(Compressor.prototype, {
|
||||
var indexFns = makePredicate("indexOf lastIndexOf");
|
||||
var commutativeOperators = makePredicate("== === != !== * & | ^");
|
||||
function is_object(node) {
|
||||
while ((node = node.tail_node()) instanceof AST_SymbolRef) {
|
||||
node = node.fixed_value();
|
||||
if (!node) return false;
|
||||
}
|
||||
if (node instanceof AST_Assign) return node.operator == "=" && is_object(node.right);
|
||||
if (node instanceof AST_Sequence) return is_object(node.tail_node());
|
||||
if (node instanceof AST_SymbolRef) return is_object(node.fixed_value());
|
||||
return node instanceof AST_Array
|
||||
|| node instanceof AST_Lambda
|
||||
|| node instanceof AST_New
|
||||
@@ -7760,14 +7764,16 @@ merge(Compressor.prototype, {
|
||||
associative = compressor.option("unsafe_math");
|
||||
// +a - b => a - b
|
||||
// a - +b => a - b
|
||||
if (self.operator != "+") {
|
||||
if (self.left instanceof AST_UnaryPrefix && self.left.operator == "+") {
|
||||
self.left = self.left.expression;
|
||||
[ "left", "right" ].forEach(function(operand) {
|
||||
var node = self[operand];
|
||||
if (node instanceof AST_UnaryPrefix && node.operator == "+") {
|
||||
var exp = node.expression;
|
||||
if (exp.is_boolean(compressor) || exp.is_number(compressor)
|
||||
|| self.operator != "+" && exp.is_string(compressor)) {
|
||||
self[operand] = exp;
|
||||
}
|
||||
}
|
||||
if (self.right instanceof AST_UnaryPrefix && self.right.operator == "+") {
|
||||
self.right = self.right.expression;
|
||||
}
|
||||
}
|
||||
});
|
||||
case "&":
|
||||
case "|":
|
||||
case "^":
|
||||
|
||||
Reference in New Issue
Block a user