summaryrefslogtreecommitdiff
path: root/src/shared/util.c
diff options
context:
space:
mode:
authorJosh Triplett <josh@joshtriplett.org>2014-03-11 16:45:56 -0700
committerLennart Poettering <lennart@poettering.net>2014-03-12 17:02:06 +0100
commite0333c7314e89c0bc268bd20c5e247a7c907ab34 (patch)
tree5c662cb5f35346a82856fb8e7af3819d2d6e1e75 /src/shared/util.c
parent7b909d7407965c03caaba30daae7aee113627a83 (diff)
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.
Diffstat (limited to 'src/shared/util.c')
-rw-r--r--src/shared/util.c9
1 files changed, 1 insertions, 8 deletions
diff --git a/src/shared/util.c b/src/shared/util.c
index 10f113bd24..e1a1168456 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -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) {