diff options
| author | Charles <sircharlesaze@gmail.com> | 2020-03-11 21:07:32 +0100 |
|---|---|---|
| committer | Charles <sircharlesaze@gmail.com> | 2020-03-11 21:23:49 +0100 |
| commit | c128213daa677d548bfc2905496257fe4a4faf79 (patch) | |
| tree | d087ceaeff3124ff539bc05d834d79f8187d5628 /src/str/ft_strstr.c | |
| parent | 3c3f1115f6e9a9b914e2dcbd796501ca7ce85342 (diff) | |
| download | libft-c128213daa677d548bfc2905496257fe4a4faf79.tar.gz libft-c128213daa677d548bfc2905496257fe4a4faf79.tar.bz2 libft-c128213daa677d548bfc2905496257fe4a4faf79.zip | |
ft_mem* and ft_strlen optimization
Diffstat (limited to 'src/str/ft_strstr.c')
| -rw-r--r-- | src/str/ft_strstr.c | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/src/str/ft_strstr.c b/src/str/ft_strstr.c index 4d4d403..893ae1e 100644 --- a/src/str/ft_strstr.c +++ b/src/str/ft_strstr.c @@ -11,6 +11,7 @@ /* ************************************************************************** */ #include "libft.h" +#include "libft_str.h" char *ft_strstr(const char *haystack, const char *needle) { @@ -19,11 +20,5 @@ char *ft_strstr(const char *haystack, const char *needle) needle_len = ft_strlen(needle); if (needle_len == 0) return ((char*)haystack); - while (*haystack) - { - if (ft_strnequ(haystack, needle, needle_len)) - return ((char*)haystack); - haystack++; - } - return (NULL); + return (ft_memmem(haystack, ft_strlen(haystack), needle, needle_len)); } |
