Re: [PATCH] Use strchr() to search for a single character - Mailing list pgsql-hackers

From David Rowley
Subject Re: [PATCH] Use strchr() to search for a single character
Date
Msg-id CAApHDvopwsSNw1CGxuDU9i70Tj-PvzniYaNQOXbSxAJW37WiFA@mail.gmail.com
Whole thread Raw
In response to Re: [PATCH] Use strchr() to search for a single character  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: [PATCH] Use strchr() to search for a single character
List pgsql-hackers
On Wed, 23 Jul 2025 at 10:36, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>
> David Rowley <dgrowleyml@gmail.com> writes:
> > Looking at [1], it seems even ancient versions of gcc and clang
> > rewrite the strstr() into a strchr() call when the search term is a
> > single char string. So it might not be worth doing to any trouble
> > here.
>
> I was wondering if that might be true.  However, your godbolt results
> show that MSVC doesn't do this optimization, and the usage in
> pgmkdirp.c is inside "#ifdef WIN32", so maybe it's worth fixing there.

Yeah, I noticed MSVC not doing the rewrite. I didn't notice the
mentioned use case was within an #ifdef WIN32.

I'm currently thinking we should just fix the pgmkdirp.c instance and
call it good.

David



pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: index prefetching
Next
From: Sami Imseih
Date:
Subject: Re: [PATCH] Proposal to Enable/Disable Index using ALTER INDEX