[SourceSwitch] Refactor a piece of code.
Fix build failure caused by #1267.
Merge pull request #1269 from Therzok/refactorSwitches

[SourceSwitch] Refactor a piece of code.