by jqpabc123 · 2mo ago · 0 comments
I can see how this could be advantageous for moderate length patterns up to 64 bytes.
But for short registered sized patterns (4 or 8 bytes), I am somewhat skeptical of any significant advantage over a very tight, brute force register based loop comparing multi-byte chunks.
I tried to be fairly careful to not overstate the performance benefits in the original post for this reason.
This is essentially what I have have been doing for years and it is very simple. I'm sure it is not always the fastest but it's not too shabby either in the real world.
1. Linearity - the naive approach is quadratic on worst case data (imagine searching for 100 0's in a text of 0's).
2. Sublinearity - sublinear search algorithms skip over text that cannot match. They typically have the somewhat counter-intuitive property that they get much faster the longer the pattern is. So long patterns will be faster using a sub linear search algorithm.
Most of the everyday searching and parsing that I end up doing involves relatively short patterns. Maybe I am an outlier :-)