aboutsummaryrefslogtreecommitdiff
path: root/tools/js-optimizer.js
diff options
context:
space:
mode:
Diffstat (limited to 'tools/js-optimizer.js')
-rw-r--r--tools/js-optimizer.js21
1 files changed, 9 insertions, 12 deletions
diff --git a/tools/js-optimizer.js b/tools/js-optimizer.js
index 89f65eda..07317e0a 100644
--- a/tools/js-optimizer.js
+++ b/tools/js-optimizer.js
@@ -1079,18 +1079,15 @@ function optimizeShiftsAggressive(ast) {
function simplifyNotCompsDirect(node) {
if (node[0] == 'unary-prefix' && node[1] == '!') {
if (node[2][0] == 'binary') {
- if (node[2][1] == '<') {
- return ['binary', '>=', node[2][2], node[2][3]];
- } else if (node[2][1] == '>') {
- return ['binary', '<=', node[2][2], node[2][3]];
- } else if (node[2][1] == '==') {
- return ['binary', '!=', node[2][2], node[2][3]];
- } else if (node[2][1] == '!=') {
- return ['binary', '==', node[2][2], node[2][3]];
- } else if (node[2][1] == '===') {
- return ['binary', '!==', node[2][2], node[2][3]];
- } else if (node[2][1] == '!==') {
- return ['binary', '===', node[2][2], node[2][3]];
+ switch(node[2][1]) {
+ case '<': return ['binary', '>=', node[2][2], node[2][3]];
+ case '>': return ['binary', '<=', node[2][2], node[2][3]];
+ case '<=': return ['binary', '>', node[2][2], node[2][3]];
+ case '>=': return ['binary', '<', node[2][2], node[2][3]];
+ case '==': return ['binary', '!=', node[2][2], node[2][3]];
+ case '!=': return ['binary', '==', node[2][2], node[2][3]];
+ case '===': return ['binary', '!==', node[2][2], node[2][3]];
+ case '!==': return ['binary', '===', node[2][2], node[2][3]];
}
} else if (node[2][0] == 'unary-prefix' && node[2][1] == '!') {
return node[2][2];