moveit / geometric_shapes

Representation of geometric shapes
57 stars 92 forks source link

getScaledDimensions(): avoid vtable lookup #225

Closed rhaschke closed 2 years ago

rhaschke commented 2 years ago

As the concrete type is known anyway, we can skip the vtable lookup.

peci1 commented 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.

simonschmeisser commented 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.

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

https://godbolt.org/z/48dnYzE78