Compress conditions that have side effects using sequences
This commit is contained in:
@@ -2322,11 +2322,15 @@ merge(Compressor.prototype, {
|
||||
});
|
||||
}
|
||||
// x=y?1:1 --> x=1
|
||||
if (!self.condition.has_side_effects(compressor)
|
||||
&& consequent instanceof AST_Constant
|
||||
if (consequent instanceof AST_Constant
|
||||
&& alternative instanceof AST_Constant
|
||||
&& consequent.equivalent_to(alternative)) {
|
||||
return make_node_from_constant(compressor, consequent.value, self);
|
||||
if (self.condition.has_side_effects(compressor)) {
|
||||
return AST_Seq.from_array([self.condition, make_node_from_constant(compressor, consequent.value, self)]);
|
||||
} else {
|
||||
return make_node_from_constant(compressor, consequent.value, self);
|
||||
|
||||
}
|
||||
}
|
||||
return self;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user