14 Apr
2016
14 Apr
'16
3:14 p.m.
That's hard to believe. Copying a pointer should be insignificant compared to the cost of the dispatch. What does the profiler say?
Which compiler? I have found that MSVC is extremely pessimistic with this type of situation and generates unnecessary mov instructions for the pointer in the struct. You can confirm it, if your case is simple enough, by stepping through an inner loop to see if it's reloading that pointer over and over again, even though there are no instructions changing the pointer in that inner loop. -- chris