v8: split switch in two for optimization