Move offset computation out of switch-case.