Compiles patterns only once