drop local assign-only variable in return (#2587)
This commit is contained in:
@@ -4666,6 +4666,24 @@ merge(Compressor.prototype, {
|
||||
var ASSIGN_OPS = [ '+', '-', '/', '*', '%', '>>', '<<', '>>>', '|', '^', '&' ];
|
||||
var ASSIGN_OPS_COMMUTATIVE = [ '*', '|', '^', '&' ];
|
||||
OPT(AST_Assign, function(self, compressor){
|
||||
if (compressor.option("dead_code")
|
||||
&& self.left instanceof AST_SymbolRef
|
||||
&& self.left.definition().scope === compressor.find_parent(AST_Lambda)) {
|
||||
var level = 0, node, parent = self;
|
||||
do {
|
||||
node = parent;
|
||||
parent = compressor.parent(level++);
|
||||
if (parent instanceof AST_Exit) {
|
||||
if (self.operator == "=") return self.right;
|
||||
return make_node(AST_Binary, self, {
|
||||
operator: self.operator.slice(0, -1),
|
||||
left: self.left,
|
||||
right: self.right
|
||||
}).optimize(compressor);
|
||||
}
|
||||
} while (parent instanceof AST_Binary && parent.right === node
|
||||
|| parent instanceof AST_Sequence && parent.tail_node() === node);
|
||||
}
|
||||
self = self.lift_sequences(compressor);
|
||||
if (self.operator == "=" && self.left instanceof AST_SymbolRef && self.right instanceof AST_Binary) {
|
||||
// x = expr1 OP expr2
|
||||
|
||||
Reference in New Issue
Block a user