diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-12-27 12:42:42 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-12-27 12:52:48 -0800 |
commit | 9e1c9c1577669424a9c7dee86b34f20ad6366c8e (patch) | |
tree | 2a86c411ef482d0248923b5e18186d0f340049e1 | |
parent | 34278eef421e19e0df84195aeaf28724b9fccead (diff) |
handle if-chains without an else in the outliner
-rw-r--r-- | tools/js-optimizer.js | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tools/js-optimizer.js b/tools/js-optimizer.js index c63cb36a..161ed59c 100644 --- a/tools/js-optimizer.js +++ b/tools/js-optimizer.js @@ -3125,6 +3125,17 @@ function outline(ast) { parts = []; var curr = node; while (1) { + if (!curr[3]) { + // we normally expect ..if (cond) { .. } else [if (nextCond) {] (in [] is what we hope to see) + // but are now seeing ..if (cond) { .. } with no else. This might be + // ..if (cond) if (nextCond) { + // which vacuum can generate from if (cond) {} else if (nextCond), making it + // if (!cond) if (nextCond) + // so we undo that, in hopes of making it more flattenable + curr[3] = curr[2]; + curr[2] = ['block', []]; + curr[1] = simplifyNotCompsDirect(['unary-prefix', '!', curr[1]]); + } parts.push({ condition: curr[1], body: curr[2] }); curr = curr[3]; if (!curr) break; |