Compare a rolling hash of each window with the hash of the pattern, and check the characters only when they agree.
This interactive visualization needs JavaScript.