There are several disadvantages to using function pointers in this case. For example, we would be forced to pass the msg parameter as a void*, so we'd lose some compile-time security there, and potentially loss of optimization.
However, it is worth benchmarking since we'd be removing the overhead of the switch (which could be significant depending on how the compiler decides to implement it).
There are several disadvantages to using function pointers in this case. For example, we would be forced to pass the
msg
parameter as avoid*
, so we'd lose some compile-time security there, and potentially loss of optimization.However, it is worth benchmarking since we'd be removing the overhead of the switch (which could be significant depending on how the compiler decides to implement it).