optimise do{...}while(false)
Now with better heuristics to avoid issues like #1532
This commit is contained in:
parent
4b90dc1fdb
commit
67bc50db16
|
|
@ -2314,13 +2314,21 @@ merge(Compressor.prototype, {
|
|||
return make_node(AST_For, self, {
|
||||
body: self.body
|
||||
});
|
||||
} else if (compressor.option("dead_code") && self instanceof AST_While) {
|
||||
}
|
||||
if (compressor.option("dead_code") && self instanceof AST_While) {
|
||||
var a = [];
|
||||
extract_declarations_from_unreachable_code(compressor, self.body, a);
|
||||
return make_node(AST_BlockStatement, self, { body: a });
|
||||
} else {
|
||||
cond = make_node_from_constant(cond, self.condition).transform(compressor);
|
||||
self.condition = best_of_expression(cond, self.condition);
|
||||
}
|
||||
if (self instanceof AST_Do) {
|
||||
var has_loop_control = false;
|
||||
var tw = new TreeWalker(function(node) {
|
||||
if (node instanceof AST_Scope || has_loop_control) return true;
|
||||
if (node instanceof AST_LoopControl && tw.loopcontrol_target(node.label) === self)
|
||||
return has_loop_control = true;
|
||||
});
|
||||
self.walk(tw);
|
||||
if (!has_loop_control) return self.body;
|
||||
}
|
||||
}
|
||||
if (self instanceof AST_While) {
|
||||
|
|
|
|||
|
|
@ -215,8 +215,7 @@ evaluate: {
|
|||
a();
|
||||
for(;;)
|
||||
c();
|
||||
// rule disabled due to issue_1532
|
||||
do d(); while (false);
|
||||
d();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user