in-place tighten_body()
This commit is contained in:
parent
0ff3c24ad5
commit
c9d37e81d0
|
|
@ -686,8 +686,6 @@ merge(Compressor.prototype, {
|
|||
}
|
||||
} while (CHANGED && max_iter-- > 0);
|
||||
|
||||
return statements;
|
||||
|
||||
// Search from right to left for assignment-like expressions:
|
||||
// - `var a = x;`
|
||||
// - `a = x;`
|
||||
|
|
@ -984,8 +982,7 @@ merge(Compressor.prototype, {
|
|||
CHANGED = true;
|
||||
stat = stat.clone();
|
||||
stat.alternative = next;
|
||||
statements[i] = stat.transform(compressor);
|
||||
statements.length = i + 1;
|
||||
statements.splice(i, 2, stat.transform(compressor));
|
||||
continue;
|
||||
}
|
||||
//---
|
||||
|
|
@ -997,8 +994,7 @@ merge(Compressor.prototype, {
|
|||
stat.alternative = next || make_node(AST_Return, stat, {
|
||||
value: null
|
||||
});
|
||||
statements[i] = stat.transform(compressor);
|
||||
statements.length = i + 1;
|
||||
statements.splice(i, next ? 2 : 1, stat.transform(compressor));
|
||||
continue;
|
||||
}
|
||||
//---
|
||||
|
|
@ -1982,12 +1978,12 @@ merge(Compressor.prototype, {
|
|||
});
|
||||
|
||||
OPT(AST_Block, function(self, compressor){
|
||||
self.body = tighten_body(self.body, compressor);
|
||||
tighten_body(self.body, compressor);
|
||||
return self;
|
||||
});
|
||||
|
||||
OPT(AST_BlockStatement, function(self, compressor){
|
||||
self.body = tighten_body(self.body, compressor);
|
||||
tighten_body(self.body, compressor);
|
||||
switch (self.body.length) {
|
||||
case 1: return self.body[0];
|
||||
case 0: return make_node(AST_EmptyStatement, self);
|
||||
|
|
@ -2894,7 +2890,7 @@ merge(Compressor.prototype, {
|
|||
});
|
||||
|
||||
OPT(AST_Try, function(self, compressor){
|
||||
self.body = tighten_body(self.body, compressor);
|
||||
tighten_body(self.body, compressor);
|
||||
if (self.bcatch && self.bfinally && all(self.bfinally.body, is_empty)) self.bfinally = null;
|
||||
if (all(self.body, is_empty)) {
|
||||
var body = [];
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user