aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/compress.js24
1 files changed, 7 insertions, 17 deletions
diff --git a/lib/compress.js b/lib/compress.js
index 70bbb7fc..8467f96c 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -2515,7 +2515,7 @@ merge(Compressor.prototype, {
self.expression = best_of_expression(expression, self.expression);
}
if (compressor.option("dead_code")) {
- var blocks = Object.create(null);
+ var prev_block;
var decl = [];
var body = [];
var default_branch;
@@ -2542,31 +2542,21 @@ merge(Compressor.prototype, {
continue;
}
}
+ var case_side_effects = branch instanceof AST_Case && branch.expression.has_side_effects(compressor);
if (aborts(branch)) {
- var key = make_node(AST_BlockStatement, branch, branch).print_to_string();
- var block;
- if (!fallthrough && (block = blocks[key])) {
- block.body = [];
- body.splice(body.indexOf(block) + 1, 0, branch);
- } else {
- body.push(branch);
- }
+ var block = make_node(AST_BlockStatement, branch, branch).print_to_string();
+ if (!fallthrough && prev_block === block) body[body.length - 1].body = [];
+ body.push(branch);
+ prev_block = block;
fallthrough = false;
} else {
body.push(branch);
+ prev_block = null;
fallthrough = true;
}
- if (branch instanceof AST_Case && branch.expression.has_side_effects(compressor))
- blocks = Object.create(null);
- if (!fallthrough) blocks[key] = branch;
}
for (; i < len && fallthrough; i++) {
branch = self.body[i];
- if (branch instanceof AST_Case) {
- exact_match.body.push(make_node(AST_SimpleStatement, branch.expression, {
- body: branch.expression
- }));
- }
exact_match.body = exact_match.body.concat(branch.body);
fallthrough = !aborts(exact_match);
}