From e491168a81d9cfdba6b1fbc8d1bf2dc517db0ecd Mon Sep 17 00:00:00 2001 From: Darryl Abbate Date: Mon, 25 Apr 2022 23:12:41 -0700 Subject: [PATCH] s/strchr/memchr/g --- src/lib.c | 2 +- src/types.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib.c b/src/lib.c index 98b7769..7611b90 100644 --- a/src/lib.c +++ b/src/lib.c @@ -138,7 +138,7 @@ LIB_FN(getc) { static int valid_fmode(char *mode) { - return (*mode && strchr("rwa", *(mode++)) && + return (*mode && memchr("rwa", *(mode++), 3) && (*mode != '+' || ((void)(++mode), 1)) && (strspn(mode, "b") == strlen(mode))); } diff --git a/src/types.h b/src/types.h index fa4523e..7d28820 100644 --- a/src/types.h +++ b/src/types.h @@ -149,11 +149,11 @@ static inline int s_eq_fast(rf_str *s1, rf_str *s2) { } static inline int s_numunlikely(rf_str *s) { - return !s->l || !strchr("+-.0123456789", s->str[0]); + return !s->l || !memchr("+-.0123456789", s->str[0], 13); } static inline int s_haszero(rf_str *s) { - return !!strchr(s->str, '0'); + return !!memchr(s->str, '0', s->l); } rf_str *s_newstr(const char *, size_t, int);