From: Tom Lane <tgl@sss.pgh.pa.us>
To: David Rowley <dgrowleyml@gmail.com>
Cc: Dmitry Mityugov <d.mityugov@postgrespro.ru>
Cc: Corey Huinker <corey.huinker@gmail.com>
Cc: pgsql-hackers@postgresql.org
Subject: Re: [PATCH] Use strchr() to search for a single character
Date: Tue, 22 Jul 2025 18:36:24 -0400
Message-ID: <1198543.1753223784@sss.pgh.pa.us> (raw)
In-Reply-To: <CAApHDvo-9k5qrsQhO7UdX+ciSTPe6wbG2MXxcCCfZ_DdmtnbDQ@mail.gmail.com>
References: <9c1beea6c7a5e9fb6677f26620f1f257@postgrespro.ru>
<CADkLM=eZe5qp+_6ZifQhxYtvhYOTr-AydsWvXhPe2mZs=9npTw@mail.gmail.com>
<8d327aa3460fa78d0d1bdcaa46f5df78@postgrespro.ru>
<CAApHDvo-9k5qrsQhO7UdX+ciSTPe6wbG2MXxcCCfZ_DdmtnbDQ@mail.gmail.com>
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.
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: tgl@sss.pgh.pa.us, dgrowleyml@gmail.com, d.mityugov@postgrespro.ru, corey.huinker@gmail.com
Subject: Re: [PATCH] Use strchr() to search for a single character
In-Reply-To: <1198543.1753223784@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox