03.01.2018, 23:17
"case 0 .. 5:" is just shorthand for "case 0, 1, 2, 3, 4, 5:". So you are creating a switch statement with 200000 cases in, not just 3. That is why it is slow (not the only problem with your code btw). You compared it to "if (0 <= x <= 5)", but it is actually more like "if (x == 0 || x == 1 || x == 2 || x == 3 || x == 4 || x == 5)". You need to learn to use the right tool for the job, not go for the one that looks nicer then wonder why it isn't very good!