www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 23165] New: lambda functions are not inlined

https://issues.dlang.org/show_bug.cgi?id=23165

          Issue ID: 23165
           Summary: lambda functions are not inlined
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: bugzilla digitalmars.com

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;
}

--
Jun 06 2022