optimize trivial arrow functions with a return statement in braces (#1681)

fixes #1676
This commit is contained in:
kzc
2017-03-26 00:03:11 -04:00
committed by Alex Lam S.L
parent 9e2290b29c
commit 6a54de79b5
2 changed files with 21 additions and 1 deletions

View File

@@ -3943,6 +3943,14 @@ merge(Compressor.prototype, {
return self;
});
OPT(AST_Arrow, function(self, compressor){
if (self.body.length === 1 && self.body[0] instanceof AST_Return) {
var value = self.body[0].value;
self.body = value ? value : [];
}
return self;
});
OPT(AST_Class, function(self, compressor){
// HACK to avoid compress failure.
// AST_Class is not really an AST_Scope/AST_Block as it lacks a body.