chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(from parent 1:
7b909d7
)
util: Rewrite in_charset to use strspn
author
Josh Triplett
<josh@joshtriplett.org>
Tue, 11 Mar 2014 23:45:56 +0000
(16:45 -0700)
committer
Lennart Poettering
<lennart@poettering.net>
Wed, 12 Mar 2014 16:02:06 +0000
(17:02 +0100)
This simplifies in_charset down to a one-liner, and allows for possible
optimizations of strspn in libc.
src/shared/util.c
patch
|
blob
|
history
diff --git
a/src/shared/util.c
b/src/shared/util.c
index 10f113bd240975d7f9fc810c21623ad54aba2e67..e1a11684565f4bc8780422af492238271a988fa1 100644
(file)
--- 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) {