The difference in performance is due to the fact that the compiler sets up security checks as part of the A::classType1 . These settings are configured for each call, even if it is really only necessary when the find function is called.
Security checks determine whether the stack has been overwritten, potentially knocking out the stack frame, including the return address.
Changing the initial value if s_classType is a constant integer, instead of calling find leads to significantly faster calls to queryInterface1 .
Security checks can be disabled using the /GS- compiler option.
source share