in reply to Re^8: Why Boyer-Moore, Horspool, alpha-skip et.al don't work for bit strings. (Thank you Anonymonk + others.)
in thread Why Boyer-Moore, Horspool, alpha-skip et.al don't work for bit strings. (And is there an alternative that does?)
Indeed. Horspool, QuickSearch, and the version by anony-me are all subtly different.
Horspool does not insert the last character/fragment into the shift table. Compare is triggered when the test fragment matches the needle end (the latter is loop invariant, fetch before loop).
Quick Search does insert the last fragment. The window and the shifts are one larger; the test position one further. But then, each iteration does a full compare unconditionally.
They both have a loop dependency on the table element. If the table is not densely populated, it can be beneficial to split the loop increment to either side of the test-and-branch. A pos += max_shift on the branch-predicted path has no memory dependency, thus allowing the loop to run speculatively ahead several iterations.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^10: Why Boyer-Moore, Horspool, alpha-skip et.al don't work for bit strings. (Thank you Anonymonk + others.)
by BrowserUk (Patriarch) on Apr 08, 2015 at 17:43 UTC |