The point of computed goto it **not** that an array lookup can be used, 
compilers do that for `switch` too and Nim helps the C compilers by injecting 
something like `default: unreachable()` for exhaustive case statements, so that 
the index check before the array is accessed can be eliminated. (Something 
which the oh-so-efficient-C cannot do with its weakly typed enums.)

The point of computed goto is to **duplicate** the dispatching logic so that 
the branch predictors in the CPU have multiple different conditions to predict. 
This may sound weird, but consider that in an interpreter you have correlations 
between your opcodes, for example, "after a push instruction a call instruction 
is more likely to follow" and duplicating of the dispatching logic takes 
advantage of these correlations.

This only makes sense when your `case` is within a loop, it's not generally 
applicable for `case` statements.

Reply via email to