diff options
author | Mattias Andrée <maandree@operamail.com> | 2015-11-13 22:01:11 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2015-11-13 22:01:11 +0100 |
commit | 3ebcc813dc643fc0853ebc159fa5b6e747258933 (patch) | |
tree | 448a287a5ed02ca8705538d71215431840b94816 /src/string/strstr.c | |
parent | add todos (diff) | |
download | slibc-3ebcc813dc643fc0853ebc159fa5b6e747258933.tar.gz slibc-3ebcc813dc643fc0853ebc159fa5b6e747258933.tar.bz2 slibc-3ebcc813dc643fc0853ebc159fa5b6e747258933.tar.xz |
improve performance on strstr and wcsstr if the needle is one character wide
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'src/string/strstr.c')
-rw-r--r-- | src/string/strstr.c | 2 |
1 files changed, 2 insertions, 0 deletions
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)); } |