Original Post
If you call a virtual function of a class many times in a row, in an inner loop, does a C++ program resolve the vtable every time again, or will the compiler optimize it so that it knows it's calling the exact same function every time in the inner loop and keep a function pointer to it or the index in the vtable or something similar?
For example if you have a per-pixel effect (not graphics card shaders, I mean on images in regular computer RAM) implemented in an object oriented way (with an interface and many implementations of different possible per-pixel effects using virtual inheritance), and you loop through all pixels of an image: is this a good idea or is it going to be slow because it has to resolve the virtual function for every pixel again?
For example if you have a per-pixel effect (not graphics card shaders, I mean on images in regular computer RAM) implemented in an object oriented way (with an interface and many implementations of different possible per-pixel effects using virtual inheritance), and you loop through all pixels of an image: is this a good idea or is it going to be slow because it has to resolve the virtual function for every pixel again?