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