enhance inline (#3352)
This commit is contained in:
@@ -5072,7 +5072,7 @@ merge(Compressor.prototype, {
|
|||||||
}
|
}
|
||||||
} while (!(scope instanceof AST_Scope));
|
} while (!(scope instanceof AST_Scope));
|
||||||
var safe_to_inject = (!(scope instanceof AST_Toplevel) || compressor.toplevel.vars)
|
var safe_to_inject = (!(scope instanceof AST_Toplevel) || compressor.toplevel.vars)
|
||||||
&& fn.parent_scope === compressor.find_parent(AST_Scope);
|
&& (exp !== fn || fn.parent_scope === compressor.find_parent(AST_Scope));
|
||||||
var inline = compressor.option("inline");
|
var inline = compressor.option("inline");
|
||||||
if (!can_inject_vars(catches, inline >= 3 && safe_to_inject)) return false;
|
if (!can_inject_vars(catches, inline >= 3 && safe_to_inject)) return false;
|
||||||
if (!can_inject_args(catches, inline >= 2 && safe_to_inject)) return false;
|
if (!can_inject_args(catches, inline >= 2 && safe_to_inject)) return false;
|
||||||
|
|||||||
@@ -2675,3 +2675,31 @@ cross_references_3: {
|
|||||||
"9 27",
|
"9 27",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
loop_inline: {
|
||||||
|
options = {
|
||||||
|
inline: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
console.log(function(o) {
|
||||||
|
function g(p) {
|
||||||
|
return o[p];
|
||||||
|
}
|
||||||
|
function h(q) {
|
||||||
|
while (g(q));
|
||||||
|
}
|
||||||
|
return h;
|
||||||
|
}([ 1, "foo", 0 ])(2));
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log(function(o) {
|
||||||
|
return function(q) {
|
||||||
|
while (p = q, o[p]);
|
||||||
|
var p;
|
||||||
|
};
|
||||||
|
}([ 1, "foo", 0 ])(2));
|
||||||
|
}
|
||||||
|
expect_stdout: "undefined"
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user