diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/compress.js | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/compress.js b/lib/compress.js index b66c5582..1f710f10 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -2784,6 +2784,18 @@ merge(Compressor.prototype, { } } } + if (compressor.option("evaluate") && !isLHS(self, compressor.parent())) { + var d = self.definition(); + if (d && d.constant && 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(); + var per_const_overhead = d.global || !d.references.length ? 0 + : (d.name.length + 2 + const_node_as_string.length) / d.references.length; + if (const_node_as_string.length <= original_as_string.length + per_const_overhead) + return const_node; + } + } return self; }); |