Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ueLbF-0086BO-Au for pgsql-hackers@arkaria.postgresql.org; Tue, 22 Jul 2025 22:36:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1ueLbE-00FKPZ-De for pgsql-hackers@arkaria.postgresql.org; Tue, 22 Jul 2025 22:36:40 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ueLbE-00FKPI-4G for pgsql-hackers@lists.postgresql.org; Tue, 22 Jul 2025 22:36:40 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1ueLbC-000HMT-1z for pgsql-hackers@postgresql.org; Tue, 22 Jul 2025 22:36:39 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 56MMaOWT1198544; Tue, 22 Jul 2025 18:36:24 -0400 From: Tom Lane To: David Rowley cc: Dmitry Mityugov , Corey Huinker , pgsql-hackers@postgresql.org Subject: Re: [PATCH] Use strchr() to search for a single character In-reply-to: References: <9c1beea6c7a5e9fb6677f26620f1f257@postgrespro.ru> <8d327aa3460fa78d0d1bdcaa46f5df78@postgrespro.ru> Comments: In-reply-to David Rowley message dated "Wed, 23 Jul 2025 10:18:26 +1200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1198542.1753223784.1@sss.pgh.pa.us> Date: Tue, 22 Jul 2025 18:36:24 -0400 Message-ID: <1198543.1753223784@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk David Rowley 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