2 ms·
It would not. Real world versions of what you speak would use different algorithms. If you're concerned about different normalization forms for example, the typ
by burntsushi 4y ago
It would not. Real world versions of what you speak would use different algorithms. If you're concerned about different normalization forms for example, the typical way to do that is to normalize both your needle and haystack before doing a search.
For case folding, you can enumerate at least all the possible prefixes of small length, scan for those using a SIMD algorithm like Teddy (from Hyperscan) and then use a finite state machine to confirm or reject the match. That's how Rust's regex crate (and consequently, ripgrep) works for example.
Regardless of those cases, exact string match is still very much desirable to optimize and is extremely useful in the real world.