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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: David Rowley <dgrowleyml(at)gmail(dot)com>
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:36:24
Message-ID: 1198543.1753223784@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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.

I can't get excited about dmetaphone --- that's about as old and
crufty as anything in our tree. If we were going to touch it the
first thing I'd want to do is get rid of its non-multibyte-safe
upcasing logic (MakeUpper). The "WITZ" business is kind of
silly-looking, but the question it brings to my mind is whether
the algorithm was mistranscribed; so rather than just delete that
line we should do some research. If we care, that is.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alexander Korotkov 2025-07-22 22:37:23 Re: Proposal: Limitations of palloc inside checkpointer
Previous Message David Rowley 2025-07-22 22:32:25 Re: Proposal: QUALIFY clause