util: Rewrite in_charset to use strspn

This simplifies in_charset down to a one-liner, and allows for possible
optimizations of strspn in libc.
This commit is contained in:
Josh Triplett
2014-03-12 17:02:06 +01:00
committed by Lennart Poettering
parent 7b909d7407
commit e0333c7314
+1 -8
View File
@@ -921,16 +921,9 @@ char *delete_chars(char *s, const char *bad) {
}
bool in_charset(const char *s, const char* charset) {
const char *i;
assert(s);
assert(charset);
for (i = s; *i; i++)
if (!strchr(charset, *i))
return false;
return true;
return s[strspn(s, charset)] == '\0';
}
char *file_in_same_dir(const char *path, const char *filename) {