Hi,
I want to call CTest's StaticMethod via a function pointer from Class CCaller. I noticed that StaticMethod is not inlined and the call takes much more time compared to calling the function directly. When calling directly the function gets inlined - even without the inline keyword.
Can't the function pointer call be optimized by the compiler? Are there additional keywords necessary for telling it to do so?
class CTest
{
public:
inline static void StaticMethod(void)
{
//Do something
}
};
typedef void (*tPtr)(void);
static tPtr fPointer = &CTest::StaticMethod;
class CCaller
{
public:
static void CallMethod(void)
{
//either or:
//this is pretty fast
CTest::StaticMethod();
//this is very slow
//fPointer();
}
};
Thanks in advance,
Mirco