Compress conditional assignments where all possible outcomes are equivalant and condition has no side effects
This commit is contained in:
@@ -2321,6 +2321,13 @@ merge(Compressor.prototype, {
|
||||
alternative: alternative
|
||||
});
|
||||
}
|
||||
// x=y?1:1 --> x=1
|
||||
if (!self.condition.has_side_effects(compressor)
|
||||
&& consequent instanceof AST_Constant
|
||||
&& alternative instanceof AST_Constant
|
||||
&& consequent.equivalent_to(alternative)) {
|
||||
return make_node_from_constant(compressor, consequent.value, self);
|
||||
}
|
||||
return self;
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user