sse4-strstr icon indicating copy to clipboard operation
sse4-strstr copied to clipboard

avx2_strstr_anysize does not work with pattern of size one

Open tbarbette opened this issue 4 years ago • 1 comments

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.

tbarbette avatar Apr 21 '20 12:04 tbarbette

Probably the easiest way is to have the precondition k > 1. For k == 1, we have memchr.

WojciechMula avatar Feb 22 '21 21:02 WojciechMula