aboutsummaryrefslogtreecommitdiff
path: root/lib/compress.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/compress.js')
-rw-r--r--lib/compress.js15
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)