Skip to content

Commit

Permalink
s/strchr/memchr/g
Browse files Browse the repository at this point in the history
  • Loading branch information
darrylabbate committed Apr 26, 2022
1 parent 012d823 commit e491168
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
}
Expand Down
4 changes: 2 additions & 2 deletions src/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit e491168

Please sign in to comment.