From: | David Rowley <dgrowleyml(at)gmail(dot)com> |
---|---|
To: | Dmitry Mityugov <d(dot)mityugov(at)postgrespro(dot)ru> |
Cc: | 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:18:26 |
Message-ID: | CAApHDvo-9k5qrsQhO7UdX+ciSTPe6wbG2MXxcCCfZ_DdmtnbDQ@mail.gmail.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Wed, 23 Jul 2025 at 09:34, Dmitry Mityugov <d(dot)mityugov(at)postgrespro(dot)ru> 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 than a single character on adjacent
> lines, and replacing half of those strstr()s with strchr()s would make
> the code less consistent in my opinion.
That depends on what you're making consistent. If the consistency is
that we always use strchr() when the search is for a single char, then
it's not consistent to ignore that one.
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.
[1] https://godbolt.org/z/q1xcKdzd7
David
From | Date | Subject | |
---|---|---|---|
Next Message | Joel Jacobson | 2025-07-22 22:20:29 | Re: [PATCH] Optimize ProcSignal to avoid redundant SIGUSR1 signals |
Previous Message | Dave Cramer | 2025-07-22 21:54:48 | More protocol.h replacements this time into walsender.c |