From 77bbc2d383bfc09ddaef2a5bbc5a7a05f035d299 Mon Sep 17 00:00:00 2001 From: starnakin Date: Fri, 6 Sep 2024 23:11:34 +0200 Subject: [PATCH] core: opti: strstr --- src/string/strstr.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/string/strstr.c b/src/string/strstr.c index 4586058..b035d18 100644 --- a/src/string/strstr.c +++ b/src/string/strstr.c @@ -1,14 +1,14 @@ char *strstr(const char *haystack, const char *needle) { - size_t i = 0; + const char *start = haystack; size_t len; len = strlen(needle); - while (haystack[i] != '\0') + while (*start != '\0') { - if (strncmp(haystack + i, needle, len) == 0) - return haystack + i; - i++; + if (strncmp(start, needle, len) == 0) + return start; + start++; } return NULL; }