replace (function(){ ...no side effects ... })() with undefined.
This commit is contained in:
@@ -673,16 +673,19 @@ merge(Compressor.prototype, {
|
|||||||
def(AST_EmptyStatement, function(){ return false });
|
def(AST_EmptyStatement, function(){ return false });
|
||||||
def(AST_Constant, function(){ return false });
|
def(AST_Constant, function(){ return false });
|
||||||
def(AST_This, function(){ return false });
|
def(AST_This, function(){ return false });
|
||||||
def(AST_Function, function(){ return false });
|
|
||||||
def(AST_BlockStatement, function(){
|
function block(){
|
||||||
for (var i = this.body.length; --i >= 0;) {
|
for (var i = this.body.length; --i >= 0;) {
|
||||||
if (this.body[i].has_side_effects())
|
if (this.body[i].has_side_effects())
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
};
|
||||||
|
def(AST_Block, block);
|
||||||
|
def(AST_BlockStatement, block);
|
||||||
|
|
||||||
def(AST_SimpleStatement, function(){
|
def(AST_SimpleStatement, function(){
|
||||||
|
if (this.body instanceof AST_Function) return false;
|
||||||
return this.body.has_side_effects();
|
return this.body.has_side_effects();
|
||||||
});
|
});
|
||||||
def(AST_Binary, function(){
|
def(AST_Binary, function(){
|
||||||
@@ -1281,6 +1284,13 @@ merge(Compressor.prototype, {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (compressor.option("side_effects")) {
|
||||||
|
if (self.expression instanceof AST_Function
|
||||||
|
&& self.args.length == 0
|
||||||
|
&& !self.expression.has_side_effects()) {
|
||||||
|
return make_node(AST_Undefined, self);
|
||||||
|
}
|
||||||
|
}
|
||||||
return self;
|
return self;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user