title: vftable performance penalty vs. switch statement
body: <p>C++ question here.  I have a system where I'm going to have hundreds of mini-subclasses of a given superclass.  They all will have a "foo" method that does something.  Or... I'm going to have one class with an integer called "type" and use a giant switch statement to decide what to do when I foo.</p>
  
  <p>Performance is a huge consideration here.  Extremely important.</p>
  
  <p>The question is, what are the performance benefits/penalties of using a switch statement vs. letting C++ do it via the vftable?  If I have it as a switch statement, I can put the commonly occuring foo's up at the top of the switch statement and the less common ones at the bottom, hopefully shortcutting the comparison.  Trying to get an effect like this with the vftable is bound to be compiler dependent even if I can figure out how to do it...</p>
  
  <p>On the other hand, my code would be a lot easier to deal with without these ugly switch statements.</p>