Don't get stuck in code optimising it.
Typically the few ms you gain using a hash Vs an if/else is negligible to the read/write operation over a network or db that you may also have.
Optimise those instead with a cache and/or CQRS.
I've had quite a few junior devs ask me the above, so it's not always intuitive.