diff options
author | Mihai Bazon <mihai@bazon.net> | 2012-10-08 12:53:17 +0300 |
---|---|---|
committer | Mihai Bazon <mihai@bazon.net> | 2012-10-08 12:53:17 +0300 |
commit | 093a9031dc15b2e2bd85850f3f3eb7fe90f01bd7 (patch) | |
tree | fb2d9cc85e9d74cbb13699733b32a2bf8c8d478a /lib/compress.js | |
parent | 80a18fe2fa60d8a689516b921a386839d30b6abe (diff) | |
download | tracifyjs-093a9031dc15b2e2bd85850f3f3eb7fe90f01bd7.tar.gz tracifyjs-093a9031dc15b2e2bd85850f3f3eb7fe90f01bd7.zip |
eliminate redundant directives in the same scope
Diffstat (limited to 'lib/compress.js')
-rw-r--r-- | lib/compress.js | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/compress.js b/lib/compress.js index 84f66b3c..3d55ecc1 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -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); } |