3 ms·
I find Horspool is almost always faster than Boyer Moore. For very short needles though (e.g. less than 8) it is hard to beat the SHIFT OR algorithm. Even th
by MattPalmer1086 6y ago
I find Horspool is almost always faster than Boyer Moore.
For very short needles though (e.g. less than 8) it is hard to beat the SHIFT OR algorithm.
Even though it is not sublinear, looking at every position, it tracks matches using a bitmask. In practice this is very fast and has very good cache hits. It easily beats BM or Horspool by quite a margin. They rely for speed in skips, and you don't get great skips with a short needle.