remove the $self hack

operations are destructive anyway, so there's no point to clone the nodes in
the transformer.  speed++
This commit is contained in:
Mihai Bazon
2012-10-12 11:07:35 +03:00
parent 731fa9c236
commit 1b6f8d463f
2 changed files with 11 additions and 20 deletions

View File

@@ -80,7 +80,6 @@ merge(Compressor.prototype, {
},
before: function(node, descend, in_list) {
if (node._squeezed) return node;
this.stack[this.stack.length - 1] = node = node.clone();
if (node instanceof AST_Scope) {
node.drop_unused(this);
node = node.hoist_declarations(this);
@@ -291,7 +290,7 @@ merge(Compressor.prototype, {
var ab = aborts(stat.body);
if (ab && ((ab instanceof AST_Return && !ab.value && in_lambda)
|| (ab instanceof AST_Continue && self.$self === compressor.loopcontrol_target(ab.label)))) {
|| (ab instanceof AST_Continue && self === compressor.loopcontrol_target(ab.label)))) {
CHANGED = true;
var body = as_statement_array(stat.body).slice(0, -1);
stat = stat.clone();
@@ -308,7 +307,7 @@ merge(Compressor.prototype, {
var ab = aborts(stat.alternative);
if (ab && ((ab instanceof AST_Return && !ab.value && in_lambda)
|| (ab instanceof AST_Continue && self.$self === compressor.loopcontrol_target(ab.label)))) {
|| (ab instanceof AST_Continue && self === compressor.loopcontrol_target(ab.label)))) {
CHANGED = true;
stat = stat.clone();
stat.body = make_node(AST_BlockStatement, stat.body, {
@@ -447,7 +446,6 @@ merge(Compressor.prototype, {
stat.walk(new TreeWalker(function(node){
if (node instanceof AST_Definitions) {
compressor.warn("Declarations in unreachable code! [{file}:{line},{col}]", node.start);
node = node.clone();
node.remove_initializers();
target.push(node);
return true;
@@ -1187,7 +1185,7 @@ merge(Compressor.prototype, {
var last_branch = self.body[self.body.length - 1];
if (last_branch) {
var stat = last_branch.body[last_branch.body.length - 1]; // last statement
if (stat instanceof AST_Break && compressor.loopcontrol_target(stat.label) === self.$self)
if (stat instanceof AST_Break && compressor.loopcontrol_target(stat.label) === self)
last_branch.body.pop();
}
return self;
@@ -1204,11 +1202,7 @@ merge(Compressor.prototype, {
});
AST_Definitions.DEFMETHOD("remove_initializers", function(){
this.definitions = this.definitions.map(function(def){
def = def.clone();
def.value = null;
return def;
});
this.definitions.forEach(function(def){ def.value = null });
});
AST_Definitions.DEFMETHOD("to_assignments", function(){