KMP precomputes the longest proper prefix that is also a suffix (LPS) for each pattern prefix. On mismatch, it shifts the pattern using the LPS value instead of moving the text pointer back, so characters in the text are not re-checked.