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

2025-07-22 Thread David Rowley
On Wed, 23 Jul 2025 at 11:06, Tom Lane wrote: > > David Rowley writes: > > I'm currently thinking we should just fix the pgmkdirp.c instance and > > call it good. > > +1 Done. David

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

2025-07-22 Thread Tom Lane
David Rowley writes: > I'm currently thinking we should just fix the pgmkdirp.c instance and > call it good. +1 regards, tom lane

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

2025-07-22 Thread David Rowley
On Wed, 23 Jul 2025 at 10:36, Tom Lane wrote: > > 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

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

2025-07-22 Thread Tom Lane
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 re

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

2025-07-22 Thread David Rowley
On Wed, 23 Jul 2025 at 09:34, Dmitry Mityugov wrote: > Thank you for your attention to this problem. The code in > contrib/fuzzystrmatch/dmetaphone.c indeed uses several calls to strstr() > to search for a single character, but it also uses strstr() to search > for strings that consist of more tha

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

2025-07-22 Thread Dmitry Mityugov
Corey Huinker писал(а) 2025-07-22 22:42: On Sun, Jul 20, 2025 at 6:21 PM Dmitry Mityugov wrote: Code in src/port/pgmkdirp.c uses strstr() to find a single character in a string, but strstr() seems to be too generic for this job. Another function, strchr(), might be better suited for this purp

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

2025-07-22 Thread Corey Huinker
On Sun, Jul 20, 2025 at 6:21 PM Dmitry Mityugov wrote: > Code in src/port/pgmkdirp.c uses strstr() to find a single character in > a string, but strstr() seems to be too generic for this job. Another > function, strchr(), might be better suited for this purpose, because it > is optimized to searc

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

2025-07-20 Thread Dmitry Mityugov
strchr() is used, the compiler doesn't have to generate a terminating \0 byte for the substring, producing slightly smaller code. I'm attaching the patch. Regards, DmitryFrom: Dmitry Mityugov Date: Mon, 21 Jul 2025 00:50:35 +0300 Subject: [PATCH] Use strchr() to search for a single chara