enhance dead_code (#5130)
This commit is contained in:
@@ -3331,14 +3331,11 @@ merge(Compressor.prototype, {
|
||||
var stat = statements[i];
|
||||
if (stat instanceof AST_LoopControl) {
|
||||
var lct = compressor.loopcontrol_target(stat);
|
||||
if (stat instanceof AST_Break
|
||||
&& !(lct instanceof AST_IterationStatement)
|
||||
&& loop_body(lct) === self
|
||||
|| stat instanceof AST_Continue
|
||||
&& loop_body(lct) === self) {
|
||||
if (stat.label) remove(stat.label.thedef.references, stat);
|
||||
} else {
|
||||
if (loop_body(lct) !== self
|
||||
|| stat instanceof AST_Break && lct instanceof AST_IterationStatement) {
|
||||
statements[n++] = stat;
|
||||
} else if (stat.label) {
|
||||
remove(stat.label.thedef.references, stat);
|
||||
}
|
||||
} else {
|
||||
statements[n++] = stat;
|
||||
@@ -5485,6 +5482,21 @@ merge(Compressor.prototype, {
|
||||
return compressor.option("unused") && self.label.references.length == 0 ? self.body : self;
|
||||
});
|
||||
|
||||
OPT(AST_LoopControl, function(self, compressor) {
|
||||
if (!compressor.option("dead_code")) return self;
|
||||
var label = self.label;
|
||||
if (label) {
|
||||
var lct = compressor.loopcontrol_target(self);
|
||||
self.label = null;
|
||||
if (compressor.loopcontrol_target(self) === lct) {
|
||||
remove(label.thedef.references, self);
|
||||
} else {
|
||||
self.label = label;
|
||||
}
|
||||
}
|
||||
return self;
|
||||
});
|
||||
|
||||
OPT(AST_Block, function(self, compressor) {
|
||||
self.body = tighten_body(self.body, compressor);
|
||||
return self;
|
||||
|
||||
Reference in New Issue
Block a user