Recently, I was digging into VVVVVVV’s source code that was released on GitHub by Terry Cavanagh. I went into the
Game.cpp file, and found that it contains an absolutely gigantic, 3000+ case long
switch statement in what is seemingly a function that is called consistently, not just once.
This made me ponder about how efficient
switch statements are, and I realized I don’t know much about their difference to normal
if-else chains. Are
switch statements normally used in this manner to implement state handling, and why doesn’t something like this lag the game like crazy? (I’m assuming a massive amount of comparisons are being made every time)