minimise `reduce_vars` cloning overhead (#2148)
authorAlex Lam S.L <alexlamsl@gmail.com>
Thu, 22 Jun 2017 22:59:53 +0000 (06:59 +0800)
committerGitHub <noreply@github.com>
Thu, 22 Jun 2017 22:59:53 +0000 (06:59 +0800)
lib/compress.js

index c332282..8890759 100644 (file)
@@ -3887,7 +3887,7 @@ merge(Compressor.prototype, {
             var d = self.definition();
             var fixed = self.fixed_value();
             if (fixed instanceof AST_Defun) {
-                d.fixed = fixed = make_node(AST_Function, fixed, fixed).clone(true);
+                d.fixed = fixed = make_node(AST_Function, fixed, fixed);
             }
             if (compressor.option("unused")
                 && fixed instanceof AST_Function
@@ -3895,7 +3895,7 @@ merge(Compressor.prototype, {
                 && !(d.scope.uses_arguments && d.orig[0] instanceof AST_SymbolFunarg)
                 && !d.scope.uses_eval
                 && compressor.find_parent(AST_Scope) === fixed.parent_scope) {
-                return fixed;
+                return fixed.clone(true);
             }
             if (compressor.option("evaluate") && fixed) {
                 if (d.should_replace === undefined) {