minor
This commit is contained in:
@@ -1477,7 +1477,21 @@ merge(Compressor.prototype, {
|
|||||||
return this;
|
return this;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var commutativeOperators = makePredicate("== === != !== * & | ^");
|
||||||
|
|
||||||
OPT(AST_Binary, function(self, compressor){
|
OPT(AST_Binary, function(self, compressor){
|
||||||
|
function reverse(op) {
|
||||||
|
if (op) self.operator = op;
|
||||||
|
var tmp = self.left;
|
||||||
|
self.left = self.right;
|
||||||
|
self.right = tmp;
|
||||||
|
};
|
||||||
|
if (commutativeOperators(self.operator)) {
|
||||||
|
if (self.right instanceof AST_Constant
|
||||||
|
&& !(self.left instanceof AST_Constant)) {
|
||||||
|
reverse();
|
||||||
|
}
|
||||||
|
}
|
||||||
self = self.lift_sequences(compressor);
|
self = self.lift_sequences(compressor);
|
||||||
if (compressor.option("comparisons")) switch (self.operator) {
|
if (compressor.option("comparisons")) switch (self.operator) {
|
||||||
case "===":
|
case "===":
|
||||||
@@ -1489,11 +1503,6 @@ merge(Compressor.prototype, {
|
|||||||
// XXX: intentionally falling down to the next case
|
// XXX: intentionally falling down to the next case
|
||||||
case "==":
|
case "==":
|
||||||
case "!=":
|
case "!=":
|
||||||
if (self.right instanceof AST_Constant && !(self.left instanceof AST_Constant)) {
|
|
||||||
var tmp = self.left;
|
|
||||||
self.left = self.right;
|
|
||||||
self.right = tmp;
|
|
||||||
}
|
|
||||||
if (self.left instanceof AST_String
|
if (self.left instanceof AST_String
|
||||||
&& self.left.value == "undefined"
|
&& self.left.value == "undefined"
|
||||||
&& self.right instanceof AST_UnaryPrefix
|
&& self.right instanceof AST_UnaryPrefix
|
||||||
@@ -1560,12 +1569,6 @@ merge(Compressor.prototype, {
|
|||||||
});
|
});
|
||||||
self = best_of(self, negated);
|
self = best_of(self, negated);
|
||||||
}
|
}
|
||||||
var reverse = function(op) {
|
|
||||||
self.operator = op;
|
|
||||||
var tmp = self.left;
|
|
||||||
self.left = self.right;
|
|
||||||
self.right = tmp;
|
|
||||||
};
|
|
||||||
switch (self.operator) {
|
switch (self.operator) {
|
||||||
case "<": reverse(">"); break;
|
case "<": reverse(">"); break;
|
||||||
case "<=": reverse(">="); break;
|
case "<=": reverse(">="); break;
|
||||||
|
|||||||
Reference in New Issue
Block a user