Carry a whole string-search automaton inside a single integer. Precompute a bitmask per character (bit j is 0 where the pattern has that char at position j). Then per text character: R = (R << 1) | mask[c]. When the high bit of R drops to 0, the pattern just matched. No tables the size of the text, no backtracking — and it extends to fuzzy matching by carrying a few extra words.
Each pattern character gets a mask with a 0 at the positions it occupies. State R starts all-ones. Reading text char c, shift R left and OR in mask[c]; a run of matched characters walks a 0 up through R, and when bit m−1 reaches 0 the whole pattern has matched. Type a text and pattern; watch R evolve in binary. live demo
“Shift-Or is Shift-And” — no; the original is Shift-OR, where 0 means match (counter-intuitive) and it saves one op per char. cited
Don’t over-correct the other way: Domolki built a parser recognizer, not “the bitap algorithm” — string search is genuinely Baeza-Yates & Gonnet’s reading. Baeza-Yates & Gonnet, 1989/1992
The whole automaton is one integer and two bitwise ops per character — and the match lands where it should: