diff options
author | Alon Zakai <alonzakai@gmail.com> | 2014-03-17 14:43:20 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2014-03-17 17:56:17 -0700 |
commit | c998e415c680013d5a6fdeb2e13335ba8adb580a (patch) | |
tree | 69f82de2f53a85f8984a60b46ab7634194df5c6e /tools/js-optimizer.js | |
parent | c422f49120d0ef0304213abda37de66d3b26f4c0 (diff) |
flip a non-existent else block in simplifyIfs, if adding such a block can help
Diffstat (limited to 'tools/js-optimizer.js')
-rw-r--r-- | tools/js-optimizer.js | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/tools/js-optimizer.js b/tools/js-optimizer.js index 88bcf503..129c493f 100644 --- a/tools/js-optimizer.js +++ b/tools/js-optimizer.js @@ -861,16 +861,18 @@ function simplifyIfs(ast) { node[1] = flipCondition(node[1]); node[2] = node[3]; node[3] = body; + body = node[2]; } else break; } else break; } // we can handle elses, but must be fully identical if (node[3] || other[3]) { - if (!node[3] || !other[3]) break; + if (!node[3]) break; if (!astCompare(node[3], other[3])) { // the elses are different, but perhaps if we flipped a condition we can do better if (astCompare(node[3], other[2])) { - // flip other + // flip other. note that other may not have had an else! add one if so; we will eliminate such things later + if (!other[3]) other[3] = ['block', []]; other[1] = flipCondition(other[1]); var temp = other[2]; other[2] = other[3]; |