aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMihai Bazon <mihai@bazon.net>2012-10-19 12:57:29 +0300
committerMihai Bazon <mihai@bazon.net>2012-10-19 12:57:29 +0300
commitfc8314e810c91431cd18fa9a784adb7867726013 (patch)
treeac2f5b61d8558a4e310bdb92498c186e5ee2c0a8 /lib
parent6f45928a73009b6b1aee8c1886f08ff5b83e6cb1 (diff)
downloadtracifyjs-fc8314e810c91431cd18fa9a784adb7867726013.tar.gz
tracifyjs-fc8314e810c91431cd18fa9a784adb7867726013.zip
minor fix for dropping unused definitions.
function f(x, y) { var g = function() { return h() }; var h = function() { return g() }; return x + y; } now compresses to `function f(x, y) { return x + y }`
Diffstat (limited to 'lib')
-rw-r--r--lib/compress.js5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/compress.js b/lib/compress.js
index cde4b6f7..3e5b524d 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -741,9 +741,10 @@ merge(Compressor.prototype, {
});
def(AST_SimpleStatement, function(){
- if (this.body instanceof AST_Function) return false;
return this.body.has_side_effects();
});
+ def(AST_Defun, function(){ return true });
+ def(AST_Function, function(){ return false });
def(AST_Binary, function(){
return this.left.has_side_effects()
|| this.right.has_side_effects();
@@ -1354,7 +1355,7 @@ merge(Compressor.prototype, {
if (compressor.option("side_effects")) {
if (self.expression instanceof AST_Function
&& self.args.length == 0
- && !self.expression.has_side_effects()) {
+ && !AST_Block.prototype.has_side_effects.call(self.expression)) {
return make_node(AST_Undefined, self).transform(compressor);
}
}