4 ms·
You’d be much better off with an FSA or (honestly) Boyer-Moore implementation. For a baseline, a simple fgrep should show you FSA speed. You might want to read
by stochastic_monk 9y ago
You’d be much better off with an FSA or (honestly) Boyer-Moore implementation. For a baseline, a simple fgrep should show you FSA speed.
You might want to read about classical string search algorithms. Your naive algorithm is straightforward but far from ideal.