improve reduction of AST_BlockStatement (#3708)
This commit is contained in:
@@ -116,10 +116,10 @@ module.exports = function reduce_test(testcase, minify_options, reduce_options)
|
|||||||
][ ((node.start._permute += step) * steps | 0) % 3 ];
|
][ ((node.start._permute += step) * steps | 0) % 3 ];
|
||||||
}
|
}
|
||||||
else if (node instanceof U.AST_BlockStatement) {
|
else if (node instanceof U.AST_BlockStatement) {
|
||||||
if (node.body.length === 1) {
|
if (in_list) {
|
||||||
node.start._permute++;
|
node.start._permute++;
|
||||||
CHANGED = true;
|
CHANGED = true;
|
||||||
return node.body[0]; // each child is an AST_Statement
|
return List.splice(node.body);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (node instanceof U.AST_Call) {
|
else if (node instanceof U.AST_Call) {
|
||||||
@@ -274,20 +274,13 @@ module.exports = function reduce_test(testcase, minify_options, reduce_options)
|
|||||||
|
|
||||||
// replace or skip statement
|
// replace or skip statement
|
||||||
if (node instanceof U.AST_Statement) {
|
if (node instanceof U.AST_Statement) {
|
||||||
if (node instanceof U.AST_BlockStatement
|
if (node instanceof U.AST_LabeledStatement
|
||||||
&& ( parent instanceof U.AST_IterationStatement
|
&& node.body instanceof U.AST_Statement) {
|
||||||
|| parent instanceof U.AST_Switch)) {
|
|
||||||
// don't drop the block of a switch or loop
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (node instanceof U.AST_LabeledStatement) {
|
|
||||||
if (node.body instanceof U.AST_Statement) {
|
|
||||||
// replace labelled statement with its non-labelled body
|
// replace labelled statement with its non-labelled body
|
||||||
node.start._permute = REPLACEMENTS.length;
|
node.start._permute = REPLACEMENTS.length;
|
||||||
CHANGED = true;
|
CHANGED = true;
|
||||||
return node.body;
|
return node.body;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
node.start._permute++;
|
node.start._permute++;
|
||||||
CHANGED = true;
|
CHANGED = true;
|
||||||
return List.skip;
|
return List.skip;
|
||||||
|
|||||||
Reference in New Issue
Block a user