Re: [PATCH] Use strchr() to search for a single character

From: David Rowley <dgrowleyml(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Dmitry Mityugov <d(dot)mityugov(at)postgrespro(dot)ru>, Corey Huinker <corey(dot)huinker(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: [PATCH] Use strchr() to search for a single character
Date: 2025-07-22 22:58:51
Message-ID: CAApHDvopwsSNw1CGxuDU9i70Tj-PvzniYaNQOXbSxAJW37WiFA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, 23 Jul 2025 at 10:36, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
> David Rowley <dgrowleyml(at)gmail(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Sami Imseih 2025-07-22 23:04:50 Re: [PATCH] Proposal to Enable/Disable Index using ALTER INDEX
Previous Message Andres Freund 2025-07-22 22:53:52 Re: index prefetching