Reverted previous addition of compression of conditionals where the condition and consequent are equivalent.
This commit is contained in:
parent
cd44892301
commit
a16d1d1d12
|
|
@ -2332,15 +2332,6 @@ merge(Compressor.prototype, {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// x=y?y:z --> x=y||z
|
|
||||||
if (self.condition.equivalent_to(consequent)
|
|
||||||
&& !self.condition.has_side_effects(compressor)) {
|
|
||||||
return make_node(AST_Binary, self.condition, {
|
|
||||||
left: self.condition,
|
|
||||||
operator: "||",
|
|
||||||
right: alternative
|
|
||||||
});
|
|
||||||
}
|
|
||||||
// x=y?true:false --> x=!!y
|
// x=y?true:false --> x=!!y
|
||||||
if (consequent instanceof AST_True
|
if (consequent instanceof AST_True
|
||||||
&& alternative instanceof AST_False) {
|
&& alternative instanceof AST_False) {
|
||||||
|
|
|
||||||
|
|
@ -294,42 +294,6 @@ cond_7: {
|
||||||
}
|
}
|
||||||
|
|
||||||
cond_8: {
|
cond_8: {
|
||||||
options = {
|
|
||||||
conditionals: true,
|
|
||||||
evaluate : true
|
|
||||||
};
|
|
||||||
input: {
|
|
||||||
// compress these
|
|
||||||
a = condition ? condition : b;
|
|
||||||
|
|
||||||
if (condition) {
|
|
||||||
a = condition;
|
|
||||||
} else {
|
|
||||||
a = b;
|
|
||||||
}
|
|
||||||
|
|
||||||
a = condition ? condition : b();
|
|
||||||
|
|
||||||
// Don't compress conditions that have side effects
|
|
||||||
if (condition()) {
|
|
||||||
a = condition();
|
|
||||||
} else {
|
|
||||||
a = b;
|
|
||||||
}
|
|
||||||
|
|
||||||
a = condition() ? condition() : b;
|
|
||||||
|
|
||||||
}
|
|
||||||
expect: {
|
|
||||||
a = condition || b;
|
|
||||||
a = condition || b;
|
|
||||||
a = condition || b();
|
|
||||||
a = condition() ? condition() : b;
|
|
||||||
a = condition() ? condition() : b;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
cond_9: {
|
|
||||||
options = {
|
options = {
|
||||||
conditionals: true,
|
conditionals: true,
|
||||||
evaluate : true
|
evaluate : true
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user