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