Factor code that's common to all switch cases out of the switch.