From: Rich Felker Date: Fri, 2 Nov 2018 16:01:37 +0000 (-0400) Subject: fix spuriously slow check in twoway strstr/memmem cores X-Git-Tag: v1.1.21~31 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=8f5a820d147da36bcdbddd201b35d293699dacd8;p=oweals%2Fmusl.git fix spuriously slow check in twoway strstr/memmem cores mem0 && mem && ... is redundant since mem can only be nonzero when mem0 is nonzero. --- diff --git a/src/string/memmem.c b/src/string/memmem.c index 54a66e46..ce3cd190 100644 --- a/src/string/memmem.c +++ b/src/string/memmem.c @@ -100,7 +100,7 @@ static char *twoway_memmem(const unsigned char *h, const unsigned char *z, const if (BITOP(byteset, h[l-1], &)) { k = l-shift[h[l-1]]; if (k) { - if (mem0 && mem && k < p) k = l-p; + if (mem && k < p) k = l-p; h += k; mem = 0; continue; diff --git a/src/string/strstr.c b/src/string/strstr.c index cd069127..c80e9caf 100644 --- a/src/string/strstr.c +++ b/src/string/strstr.c @@ -110,7 +110,7 @@ static char *twoway_strstr(const unsigned char *h, const unsigned char *n) k = l-shift[h[l-1]]; //printf("adv by %zu (on %c) at [%s] (%zu;l=%zu)\n", k, h[l-1], h, shift[h[l-1]], l); if (k) { - if (mem0 && mem && k < p) k = l-p; + if (mem && k < p) k = l-p; h += k; mem = 0; continue;