sse4-strstr
sse4-strstr copied to clipboard
avx2_strstr_anysize does not work with pattern of size one
With patterns that are a single character, the line: https://github.com/WojciechMula/sse4-strstr/blob/9308a59891f694f63ad6e55e387d244ea7ca4209/avx2-strstr-v2.cpp#L25 will not evaluate to true as k-2 is undefined.
avx2_strstr_anysize should have a precondition to have k > 1 (and not > 0), or change that line to accept also if k == 1 (but that's sad for the non-common case), or start with a special case.
Probably the easiest way is to have the precondition k > 1
. For k == 1
, we have memchr
.