Closed rhaschke closed 2 years ago
I wasn't sure whether the compiler optimizations do not skip the vtable lookup anyways, and it seems there is actually some difference even with O2 optimizations: https://godbolt.org/z/fEE49WEdT.
LGTM.
I wasn't sure whether the compiler optimizations do not skip the vtable lookup anyways, and it seems there is actually some difference even with O2 optimizations: https://godbolt.org/z/fEE49WEdT.
It should be able to do this optimization if the function is marked final
and ~most likely~ also if the derived 'leaf' class is marked final
As the concrete type is known anyway, we can skip the vtable lookup.