eliminate redundant directives in the same scope
This commit is contained in:
@@ -194,12 +194,20 @@ merge(Compressor.prototype, {
|
|||||||
return statements;
|
return statements;
|
||||||
|
|
||||||
function eliminate_spurious_blocks(statements) {
|
function eliminate_spurious_blocks(statements) {
|
||||||
|
var seen_dirs = [];
|
||||||
return statements.reduce(function(a, stat){
|
return statements.reduce(function(a, stat){
|
||||||
if (stat instanceof AST_BlockStatement) {
|
if (stat instanceof AST_BlockStatement) {
|
||||||
CHANGED = true;
|
CHANGED = true;
|
||||||
a.push.apply(a, eliminate_spurious_blocks(stat.body));
|
a.push.apply(a, eliminate_spurious_blocks(stat.body));
|
||||||
} else if (stat instanceof AST_EmptyStatement) {
|
} else if (stat instanceof AST_EmptyStatement) {
|
||||||
CHANGED = true;
|
CHANGED = true;
|
||||||
|
} else if (stat instanceof AST_Directive) {
|
||||||
|
if (seen_dirs.indexOf(stat.value) < 0) {
|
||||||
|
a.push(stat);
|
||||||
|
seen_dirs.push(stat.value);
|
||||||
|
} else {
|
||||||
|
CHANGED = true;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
a.push(stat);
|
a.push(stat);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user