diff options
-rw-r--r-- | lib/ast.js | 46 | ||||
-rw-r--r-- | lib/compress.js | 2 |
2 files changed, 27 insertions, 21 deletions
@@ -145,12 +145,13 @@ var AST_SimpleStatement = DEFNODE("SimpleStatement", "body", { }, AST_Statement); function walk_body(node, visitor) { - if (node.body instanceof AST_Statement) { - node.body._walk(visitor); + var body = node.body; + if (body instanceof AST_Statement) { + body._walk(visitor); + } + else for (var i = 0, len = body.length; i < len; i++) { + body[i]._walk(visitor); } - else node.body.forEach(function(stat){ - stat._walk(visitor); - }); }; var AST_Block = DEFNODE("Block", "body", { @@ -371,9 +372,10 @@ var AST_Lambda = DEFNODE("Lambda", "name argnames uses_arguments", { _walk: function(visitor) { return visitor._visit(this, function(){ if (this.name) this.name._walk(visitor); - this.argnames.forEach(function(arg){ - arg._walk(visitor); - }); + var argnames = this.argnames; + for (var i = 0, len = argnames.length; i < len; i++) { + argnames[i]._walk(visitor); + } walk_body(this, visitor); }); } @@ -533,9 +535,10 @@ var AST_Definitions = DEFNODE("Definitions", "definitions", { }, _walk: function(visitor) { return visitor._visit(this, function(){ - this.definitions.forEach(function(def){ - def._walk(visitor); - }); + var definitions = this.definitions; + for (var i = 0, len = definitions.length; i < len; i++) { + definitions[i]._walk(visitor); + } }); } }, AST_Statement); @@ -573,9 +576,10 @@ var AST_Call = DEFNODE("Call", "expression args", { _walk: function(visitor) { return visitor._visit(this, function(){ this.expression._walk(visitor); - this.args.forEach(function(arg){ - arg._walk(visitor); - }); + var args = this.args; + for (var i = 0, len = args.length; i < len; i++) { + args[i]._walk(visitor); + } }); } }); @@ -742,9 +746,10 @@ var AST_Array = DEFNODE("Array", "elements", { }, _walk: function(visitor) { return visitor._visit(this, function(){ - this.elements.forEach(function(el){ - el._walk(visitor); - }); + var elements = this.elements; + for (var i = 0, len = elements.length; i < len; i++) { + elements[i]._walk(visitor); + } }); } }); @@ -756,9 +761,10 @@ var AST_Object = DEFNODE("Object", "properties", { }, _walk: function(visitor) { return visitor._visit(this, function(){ - this.properties.forEach(function(prop){ - prop._walk(visitor); - }); + var properties = this.properties; + for (var i = 0, len = properties.length; i < len; i++) { + properties[i]._walk(visitor); + } }); } }); diff --git a/lib/compress.js b/lib/compress.js index ccd6e23c..53833115 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -1911,7 +1911,7 @@ merge(Compressor.prototype, { // returned if nothing changed. function trim(nodes, compressor, first_in_statement) { var ret = [], changed = false; - for (var i = 0, ii = nodes.length; i < ii; i++) { + for (var i = 0, len = nodes.length; i < len; i++) { var node = nodes[i].drop_side_effect_free(compressor, first_in_statement); changed |= node !== nodes[i]; if (node) { |