E.g. note how both the switch- and if-based functions generate the same code using a lookup table here:
https://godbolt.org/z/qoT3M7r5G