Improve pattern matching performance.