Open kmatheussen opened 4 years ago
As far as I know, a lambda like this is not much more than a class with a few data members (captured variables) and one single method that is called when the lambda is called, so the compiler should inline it as far as I know. But I didn't do systematic benchmarking. So if you do and have results I'd be interested to hear what you found.
Also note that this is not the final optimized variant. To produce a final optimized variant all features must be there, and this code is only doing linear interpolation where it should do higher order sinc interpolation. So although I measured that this isn't slow, full optimization will have to wait until sinc interpolation is implemented.
Hi, I looked through your code and saw this: https://github.com/swesterfeld/liquidsfz/blob/74eacc59547fa7a838e4befb8b2b800e1a40547e/lib/voice.cc#L309
Have you investigated how for instance gcc or clang treats this code? Because the code is very nice, and if compilers can guarantee that everything is inlined (and no heap allocations occur), I'll probably start using local lambdas too in realtime critical code.