On Tue, 11.03.14 16:45, Josh Triplett (j...@joshtriplett.org) wrote:

Can you turn this into an inline function please? If it's that simple it
sounds better to just make it an inline function in the .h file, instead
of the .c file...

> This simplifies in_charset down to a one-liner, and allows for possible
> optimizations of strspn in libc.
> ---
>  src/shared/util.c | 9 +--------
>  1 file changed, 1 insertion(+), 8 deletions(-)
> 
> diff --git a/src/shared/util.c b/src/shared/util.c
> index d28caae..82326df 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) {


Lennart

-- 
Lennart Poettering, Red Hat
_______________________________________________
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel

Reply via email to