fix spuriously slow check in twoway strstr/memmem cores
authorRich Felker <dalias@aerifal.cx>
Fri, 2 Nov 2018 16:01:37 +0000 (12:01 -0400)
committerRich Felker <dalias@aerifal.cx>
Fri, 2 Nov 2018 16:02:09 +0000 (12:02 -0400)
mem0 && mem && ... is redundant since mem can only be nonzero when
mem0 is nonzero.

src/string/memmem.c
src/string/strstr.c

index 54a66e466aac1dce4e7312cb30206d4f52d6ab4c..ce3cd190afae6efd84cf4707dbbd181929daab50 100644 (file)
@@ -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;
index cd0691275b2e4880853837738a1569ad1d06fc80..c80e9caf6d9deb14241ba0edd9e5a0d0b349bd27 100644 (file)
@@ -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;