Re: [PATCH 3/4] diffcore-pickaxe: further refactor count_match()
René Scharfe <rene.scharfe@lsrfire.ath.cx> writes:
Show 11 quoted lines
>> -
>> - } else { /* Classic exact string match */
>> - /* Yes, I've heard of strstr(), but the thing is *data may
>> - * not be NUL terminated. Sue me.
>> - */
>> + } else {
>> + /* data many not be NUL terminated; we cannot use strstr() */
>
> That looks fishy to me. regexec() expects data to be a NUL-terminated
> string, so either the comment is wrong or the regexp case needs to take
> better care to add a NUL at the end of the buffer.Probably yes, but regexp side is not my code and I never use it, so... ;-)
> In any case, there is also memmem(), which uses the same fast algorithm
> as strstr() in recent glibc versions. Like this?
Thanks; it would be nice to bench this change.