aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-06-08 12:55:37 -0700
committerAlon Zakai <alonzakai@gmail.com>2013-06-08 12:55:37 -0700
commite2bfdef2b868c875dd2d4ae089e32d0eb5597cf2 (patch)
tree9189ab0b72430255d4fc7aece1aa53095b24ff9b /tools
parent8cc04538f5e40012b3bf9a7d0ca2cf3976dbec81 (diff)
handle more cases in simplifyNotComps
Diffstat (limited to 'tools')
-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];