diff options
author | Mihai Bazon <mihai@bazon.net> | 2013-10-04 13:17:25 +0300 |
---|---|---|
committer | Mihai Bazon <mihai@bazon.net> | 2013-10-04 13:17:25 +0300 |
commit | f2348dd98baeb7dc3e0542465ede897c15d7cbc9 (patch) | |
tree | 8a14ff70c67377e34c38598d93c377fcdb0ef484 /lib/compress.js | |
parent | 253c7c23258e9c783459f683a385bb518f18403a (diff) | |
download | tracifyjs-f2348dd98baeb7dc3e0542465ede897c15d7cbc9.tar.gz tracifyjs-f2348dd98baeb7dc3e0542465ede897c15d7cbc9.zip |
Rename clean_getters to pure_getters; add pure_funcs.
Diffstat (limited to 'lib/compress.js')
-rw-r--r-- | lib/compress.js | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/compress.js b/lib/compress.js index 76cbc748..4dd273b5 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -66,7 +66,8 @@ function Compressor(options, false_by_default) { join_vars : !false_by_default, cascade : !false_by_default, side_effects : !false_by_default, - clean_getters : false, + pure_getters : false, + pure_funcs : null, negate_iife : !false_by_default, screw_ie8 : false, @@ -809,6 +810,12 @@ merge(Compressor.prototype, { def(AST_Constant, function(compressor){ return false }); def(AST_This, function(compressor){ return false }); + def(AST_Call, function(compressor){ + var pure = compressor.option("pure_funcs"); + if (!pure) return true; + return pure.indexOf(this.expression.print_to_string()) < 0; + }); + def(AST_Block, function(compressor){ for (var i = this.body.length; --i >= 0;) { if (this.body[i].has_side_effects(compressor)) @@ -855,16 +862,16 @@ merge(Compressor.prototype, { return false; }); def(AST_Dot, function(compressor){ - if (!compressor.option("clean_getters")) return true; + if (!compressor.option("pure_getters")) return true; return this.expression.has_side_effects(compressor); }); def(AST_Sub, function(compressor){ - if (!compressor.option("clean_getters")) return true; + if (!compressor.option("pure_getters")) return true; return this.expression.has_side_effects(compressor) || this.property.has_side_effects(compressor); }); def(AST_PropAccess, function(compressor){ - return !compressor.option("clean_getters"); + return !compressor.option("pure_getters"); }); def(AST_Seq, function(compressor){ return this.car.has_side_effects(compressor) |