function if_break_in_loop(self, compressor) {
var first = first_statement(self.body);
- if (compressor.option("dead_code") && (breaks(first) || first instanceof AST_Exit)) {
+ if (compressor.option("dead_code")
+ && (first instanceof AST_Break
+ || first instanceof AST_Continue && external_target(first)
+ || first instanceof AST_Exit)) {
var body = [];
if (self.init instanceof AST_Statement) {
body.push(self.init);
}
if (first instanceof AST_If) {
var ab = first_statement(first.body);
- if (breaks(ab)) {
+ if (ab instanceof AST_Break && !external_target(ab)) {
if (self.condition) {
self.condition = make_node(AST_Binary, self.condition, {
left: self.condition,
return drop_it(body);
}
ab = first_statement(first.alternative);
- if (breaks(ab)) {
+ if (ab instanceof AST_Break && !external_target(ab)) {
if (self.condition) {
self.condition = make_node(AST_Binary, self.condition, {
left: self.condition,
return compressor.loopcontrol_target(node) !== compressor.self();
}
- function breaks(node) {
- return node instanceof AST_Break
- || node instanceof AST_Continue && external_target(node);
- }
-
function drop_it(rest) {
if (self.body instanceof AST_BlockStatement) {
self.body = self.body.clone();