| > Having to jump to another function definition which is inline is a bigger mental block than following a goto. Local lambdas are ideal for this. > Are you suggesting that the code should have done something like this? Yes, but you can manage the array inside too. > I mean, sure, it's a very minor cleanup. It changes like, two lines though The point is that TempArray can be reused everywhere. This is a typical class that many projects use (stack if small, heap is bigger than threshold). > Here's modern MSVC. Let's play "spot the difference" The optimizer has been asked to leave everything as it is, so that is the expected result. BTW, MSVC is not what you should be using if you want performance. > Don't just say "should be"... test it yourself! I always test codegen for all abstractions I use! So I agree. |
The problem with lambdas, you can't mark their operator() with __forceinline or __attribute__((always_inline)) attributes. For this reason, when writing high-performance manually vectorized code, lambdas are borderline useless.
> MSVC is not what you should be using if you want performance.
Security and compatibility has higher priority. gcc and clang don't deliver their C runtime libraries with windows updates. Also, debugging and crash diagnostic is much easier with MSVC.
It's same on Linux BTW, only with gcc.