The following should inline the lambda when compiled with -inline, but does not:
int test(string type)
{
auto number = 200;
return type == "as-is"?
number:
{ number *= 2;
number += 2;
number /= 2;
number = number > 300 ? 200 : 100;
return number;
}(); // should be inlined
return number;
}
Comment #1 by dlang-bot — 2022-06-07T00:52:42Z
@WalterBright created dlang/dmd pull request #14190 "fix Issue 23165 - lambda functions are not inlined" fixing this issue:
- fix Issue 23165 - lambda functions are not inlined
https://github.com/dlang/dmd/pull/14190
Comment #2 by dlang-bot — 2022-06-07T08:46:01Z
dlang/dmd pull request #14190 "fix Issue 23165 - lambda functions are not inlined" was merged into master:
- 856c88a60888959ea7d061300d8da4d9d16fdd40 by Walter Bright:
fix Issue 23165 - lambda functions are not inlined
https://github.com/dlang/dmd/pull/14190