From 3ebcc813dc643fc0853ebc159fa5b6e747258933 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Fri, 13 Nov 2015 22:01:11 +0100 Subject: improve performance on strstr and wcsstr if the needle is one character wide MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/string/strstr.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/string') diff --git a/src/string/strstr.c b/src/string/strstr.c index a2c31f6..f396570 100644 --- a/src/string/strstr.c +++ b/src/string/strstr.c @@ -37,6 +37,8 @@ */ char* (strstr)(const char* haystack, const char* needle) { + if (*needle && !(needle[1])) + return (strchr)(haystack, *needle); return (memmem)(haystack, strlen(haystack), needle, strlen(needle)); } -- cgit v1.2.3-70-g09d2