enhance merge_vars (#5308)
This commit is contained in:
@@ -6245,8 +6245,10 @@ Compressor.prototype.compress = function(node) {
|
|||||||
|| !mergeable(head_refs, tail_refs)
|
|| !mergeable(head_refs, tail_refs)
|
||||||
|| (head_refs.start.loop || !same_scope(def)) && !mergeable(tail_refs, head_refs)
|
|| (head_refs.start.loop || !same_scope(def)) && !mergeable(tail_refs, head_refs)
|
||||||
|| compressor.option("webkit") && is_funarg(def) !== is_funarg(head.definition)
|
|| compressor.option("webkit") && is_funarg(def) !== is_funarg(head.definition)
|
||||||
|| !safe_to_rename(head_refs, def)
|
|| head.definition.const_redefs
|
||||||
|| !safe_to_rename(references[def.id], head.definition)) {
|
|| !all(head_refs, function(sym) {
|
||||||
|
return sym.scope.find_variable(def.name) === def;
|
||||||
|
})) {
|
||||||
skipped.push(head);
|
skipped.push(head);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -6348,12 +6350,6 @@ Compressor.prototype.compress = function(node) {
|
|||||||
function mergeable(head, tail) {
|
function mergeable(head, tail) {
|
||||||
return must_visit(head.start, head.end) || must_visit(head.start, tail.start);
|
return must_visit(head.start, head.end) || must_visit(head.start, tail.start);
|
||||||
}
|
}
|
||||||
|
|
||||||
function safe_to_rename(refs, def) {
|
|
||||||
return all(refs, function(sym) {
|
|
||||||
return sym.scope.find_variable(def.name) === def;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function fill_holes(orig, elements) {
|
function fill_holes(orig, elements) {
|
||||||
|
|||||||
@@ -270,8 +270,8 @@ merge_vars_3: {
|
|||||||
var b = console;
|
var b = console;
|
||||||
console.log(typeof b);
|
console.log(typeof b);
|
||||||
}
|
}
|
||||||
var a = 1;
|
var b = 1;
|
||||||
console.log(typeof a);
|
console.log(typeof b);
|
||||||
}
|
}
|
||||||
expect_stdout: [
|
expect_stdout: [
|
||||||
"object",
|
"object",
|
||||||
|
|||||||
Reference in New Issue
Block a user