js optimization switch-case