git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Martin Ågren" <martin.agren@gmail.com>
To: "René Scharfe" <l.s.r@web.de>
Cc: Git Mailing List <git@vger.kernel.org>,
	Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH] use strpbrk(3) to search for characters from a given set
Date: Sun, 23 Feb 2020 10:01:29 +0100	[thread overview]
Message-ID: <CAN0heSpwNg0MKN7SCRi9b2CnxwQdCwxpc4LEkeVV4f9mxtYkLA@mail.gmail.com> (raw)
In-Reply-To: <4140dade-d999-a74a-1f8e-06eedb84ed20@web.de>

On Sat, 22 Feb 2020 at 19:53, René Scharfe <l.s.r@web.de> wrote:
>
> We can check if certain characters are present in a string by calling
> strchr(3) on each of them, or we can pass them all to a single
> strpbrk(3) call.  The latter is shorter, less repetitive and slightly
> more efficient, so let's do that instead.
>
> Signed-off-by: René Scharfe <l.s.r@web.de>
> ---
>  builtin/show-branch.c              | 2 +-
>  compat/mingw.c                     | 2 +-
>  mailinfo.c                         | 3 +--
>  t/helper/test-windows-named-pipe.c | 2 +-
>  4 files changed, 4 insertions(+), 5 deletions(-)

I failed to identify any other spots, except for some hits in test data
(in t/t4256/1/) which are probably better left alone.

> -       if (strchr(av, '*') || strchr(av, '?') || strchr(av, '[')) {
> +       if (strpbrk(av, "*?[")) {

Indeed, the `strchr()` calls use the same haystack `av`, as opposed to
`av`/`aw` or `av++`/`av++` or so. All conversions in this patch look
good to me.

Martin

  reply	other threads:[~2020-02-23  9:01 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-22 18:51 [PATCH] use strpbrk(3) to search for characters from a given set René Scharfe
2020-02-23  9:01 ` Martin Ågren [this message]
2020-02-24  6:38 ` Jeff King
2020-02-24 17:10 ` Junio C Hamano
2020-02-24 19:01   ` René Scharfe
2020-02-24 19:10     ` Jeff King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAN0heSpwNg0MKN7SCRi9b2CnxwQdCwxpc4LEkeVV4f9mxtYkLA@mail.gmail.com \
    --to=martin.agren@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=l.s.r@web.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).