enhance inline (#4163)

This commit is contained in:
Alex Lam S.L
2020-09-30 14:03:28 +01:00
committed by GitHub
parent 1cd1a1e5ee
commit 090ee895e1
2 changed files with 25 additions and 1 deletions

View File

@@ -6831,7 +6831,7 @@ merge(Compressor.prototype, {
return arg; return arg;
})).optimize(compressor); })).optimize(compressor);
node = maintain_this_binding(compressor, compressor.parent(), compressor.self(), node); node = maintain_this_binding(compressor, compressor.parent(), compressor.self(), node);
if (replacing || best_of(compressor, self, node) === node) { if (replacing || best_of_expression(node, self) === node) {
refs.forEach(function(ref) { refs.forEach(function(ref) {
var def = ref.definition(); var def = ref.definition();
def.references.push(ref); def.references.push(ref);

View File

@@ -4829,3 +4829,27 @@ issue_4159: {
} }
expect_stdout: "42 42" expect_stdout: "42 42"
} }
direct_inline: {
options = {
inline: true,
reduce_vars: true,
unused: true,
}
input: {
function f(a, b) {
function g(c) {
return c >> 1;
}
return g(a) + g(b);
}
console.log(f(13, 31));
}
expect: {
function f(a, b) {
return (a >> 1) + (b >> 1);
}
console.log(f(13, 31));
}
expect_stdout: "21"
}