optimise do{...}while(false) (#1785)

- better heuristics to avoid issues like #1532
- fix `TreeWalker.loopcontrol_target()`
  - `continue` cannot refer to `switch` blocks
This commit is contained in:
Alex Lam S.L
2017-04-04 23:48:22 +08:00
committed by GitHub
parent 4b90dc1fdb
commit 9b6bc67c33
3 changed files with 49 additions and 19 deletions

View File

@@ -215,8 +215,7 @@ evaluate: {
a();
for(;;)
c();
// rule disabled due to issue_1532
do d(); while (false);
d();
}
}
@@ -458,3 +457,26 @@ issue_1648: {
}
expect_exact: "function f(){for(x();1;);}"
}
do_switch: {
options = {
evaluate: true,
loops: true,
}
input: {
do {
switch (a) {
case b:
continue;
}
} while (false);
}
expect: {
do {
switch (a) {
case b:
continue;
}
} while (false);
}
}