Re: [PATCH] quote: use isalnum() to check for alphanumeric characters

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, 22 Feb 2020 at 19:53, René Scharfe <l.s.r@xxxxxx> wrote:
>
> isalnum(c) is equivalent to isalpha(c) || isdigit(c), so use the
> former instead.  The result is shorter, simpler and slightly more
> efficient.

>From git-compat-util.h I can see that the claim about equivalence is
correct. And the efficiency claim, too. And agreed on "shorter and
simpler".

> --- a/quote.c
> +++ b/quote.c
> @@ -55,7 +55,7 @@ void sq_quote_buf_pretty(struct strbuf *dst, const char *src)
>         }
>
>         for (p = src; *p; p++) {
> -               if (!isalpha(*p) && !isdigit(*p) && !strchr(ok_punct, *p)) {
> +               if (!isalnum(*p) && !strchr(ok_punct, *p)) {

I failed to identify any similar constructs. Looks good to me.

Martin




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux