|
it detects whether one string is contained in another string and if it is not then determines the maximum length of the first string's prefix which constitutes the suffix of the second string ...and determines the maximum length of the first string's suffix which constitutes the prefix of the second string.
x86 CPUs can do it in two SSE/SIMD instructions when the strings are less than 17 bytes long. Longer strings have to be processed in 16 byte chunks while avoiding naively iterating over each character ...or reloading the string from memory multiple times redundantly ...or making comparisons that cannot possibly change the final result like: recomparing the same substrings or checking for containment by comparing substrings in the middle of a haystack when the needle is very long and has a small wiggle-room, etc...
|