small improvement on merging assignments into hoisted vars
authorMihai Bazon <mihai@bazon.net>
Wed, 5 Dec 2012 11:14:49 +0000 (13:14 +0200)
committerMihai Bazon <mihai@bazon.net>
Wed, 5 Dec 2012 11:14:49 +0000 (13:14 +0200)
lib/compress.js

index 2355c5e..9387a82 100644 (file)
@@ -1152,6 +1152,15 @@ merge(Compressor.prototype, {
                                 continue;
                             }
                         }
+                        if (self.body[i] instanceof AST_EmptyStatement) {
+                            self.body.splice(i, 1);
+                            continue;
+                        }
+                        if (self.body[i] instanceof AST_BlockStatement) {
+                            var tmp = [ i, 1 ].concat(self.body[i].body);
+                            self.body.splice.apply(self.body, tmp);
+                            continue;
+                        }
                         break;
                     }
                     defs = make_node(AST_Var, self, {