aboutsummaryrefslogtreecommitdiff
path: root/lib/compress.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/compress.js')
-rw-r--r--lib/compress.js12
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/compress.js b/lib/compress.js
index 95e9c1b3..2bc1c5a5 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -69,8 +69,8 @@ function Compressor(options, false_by_default) {
hoist_vars : false,
if_return : !false_by_default,
join_vars : !false_by_default,
- collapse_vars : false,
- reduce_vars : false,
+ collapse_vars : !false_by_default,
+ reduce_vars : !false_by_default,
cascade : !false_by_default,
side_effects : !false_by_default,
pure_getters : false,
@@ -1252,7 +1252,7 @@ merge(Compressor.prototype, {
this._evaluating = true;
try {
var d = this.definition();
- if ((d.constant || compressor.option("reduce_vars") && !d.modified) && d.init) {
+ if (compressor.option("reduce_vars") && !d.modified && d.init) {
if (compressor.option("unsafe")) {
if (!HOP(d.init, '_evaluated')) {
d.init._evaluated = ev(d.init, compressor);
@@ -3025,9 +3025,11 @@ merge(Compressor.prototype, {
return make_node(AST_Infinity, self).transform(compressor);
}
}
- if (compressor.option("evaluate") && !isLHS(self, compressor.parent())) {
+ if (compressor.option("evaluate")
+ && compressor.option("reduce_vars")
+ && !isLHS(self, compressor.parent())) {
var d = self.definition();
- if (d && d.constant && d.init && d.init.is_constant(compressor)) {
+ if (d.constant && !d.modified && d.init && d.init.is_constant(compressor)) {
var original_as_string = self.print_to_string();
var const_node = make_node_from_constant(compressor, d.init.constant_value(compressor), self);
var const_node_as_string = const_node.print_to_string();