@@ -4358,6 +4358,7 @@ merge(Compressor.prototype, {
|
||||
if (node.init) node.init.walk(tw);
|
||||
push();
|
||||
segment.block = node;
|
||||
segment.loop = true;
|
||||
if (node.condition) node.condition.walk(tw);
|
||||
node.body.walk(tw);
|
||||
if (node.step) node.step.walk(tw);
|
||||
@@ -4368,6 +4369,7 @@ merge(Compressor.prototype, {
|
||||
node.object.walk(tw);
|
||||
push();
|
||||
segment.block = node;
|
||||
segment.loop = true;
|
||||
node.init.walk(tw);
|
||||
node.body.walk(tw);
|
||||
pop();
|
||||
@@ -4388,6 +4390,7 @@ merge(Compressor.prototype, {
|
||||
if (node instanceof AST_IterationStatement) {
|
||||
push();
|
||||
segment.block = node;
|
||||
segment.loop = true;
|
||||
descend();
|
||||
pop();
|
||||
return true;
|
||||
@@ -4400,12 +4403,15 @@ merge(Compressor.prototype, {
|
||||
return true;
|
||||
}
|
||||
if (node instanceof AST_Scope) {
|
||||
if (node instanceof AST_Lambda) {
|
||||
references[node.variables.get("arguments").id] = false;
|
||||
if (node.name) references[node.name.definition().id] = false;
|
||||
}
|
||||
push();
|
||||
segment.block = node;
|
||||
if (node instanceof AST_Lambda) {
|
||||
if (node.name) {
|
||||
if (node !== self) segment.loop = true;
|
||||
references[node.name.definition().id] = false;
|
||||
}
|
||||
references[node.variables.get("arguments").id] = false;
|
||||
}
|
||||
descend();
|
||||
pop();
|
||||
return true;
|
||||
@@ -4487,7 +4493,9 @@ merge(Compressor.prototype, {
|
||||
var id = tail.definition.id;
|
||||
var tail_refs = references[id];
|
||||
if (!tail_refs) continue;
|
||||
if (!mergeable(head_refs, tail_refs)) {
|
||||
if (head_refs.start.block !== tail_refs.start.block
|
||||
|| !mergeable(head_refs, tail_refs)
|
||||
|| head_refs.start.loop && !mergeable(tail_refs, head_refs)) {
|
||||
skipped.unshift(tail);
|
||||
continue;
|
||||
}
|
||||
@@ -4560,7 +4568,6 @@ merge(Compressor.prototype, {
|
||||
}
|
||||
|
||||
function mergeable(head, tail) {
|
||||
if (head.start.block !== tail.start.block) return false;
|
||||
return must_visit(head.start, head.end) || must_visit(head.start, tail.start);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user