Can we take the if/case match out of the for loop? It is better not to rely on branch prediction for speeding up the pattern matching performance.