That's because that type of code is actually better performing than the dynamic dispatch.

There's absolutely nothing wrong with this code. It's just that it's not as extensible

It's a 'closed world' representation where the code assumes it knows about every possibility. This make extension more difficult

The code itself is extraordinarily good and performant.