optimize return undefined and return void 0
This commit is contained in:
@@ -65,6 +65,7 @@ function Compressor(options, false_by_default) {
|
||||
keep_fnames : false,
|
||||
hoist_vars : false,
|
||||
if_return : !false_by_default,
|
||||
return_void_0 : !false_by_default,
|
||||
join_vars : !false_by_default,
|
||||
cascade : !false_by_default,
|
||||
side_effects : !false_by_default,
|
||||
@@ -2519,4 +2520,13 @@ merge(Compressor.prototype, {
|
||||
OPT(AST_Object, literals_in_boolean_context);
|
||||
OPT(AST_RegExp, literals_in_boolean_context);
|
||||
|
||||
OPT(AST_Return, function(self, compressor){
|
||||
if (compressor.option("return_void_0")) {
|
||||
if (self.value instanceof AST_Undefined) {
|
||||
self.value = null;
|
||||
}
|
||||
}
|
||||
return self;
|
||||
});
|
||||
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user