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

Поиск
Список
Период
Сортировка
От David Rowley
Тема Re: [PATCH] Use strchr() to search for a single character
Дата
Msg-id CAApHDvo-9k5qrsQhO7UdX+ciSTPe6wbG2MXxcCCfZ_DdmtnbDQ@mail.gmail.com
обсуждение исходный текст
Ответ на Re: [PATCH] Use strchr() to search for a single character  (Dmitry Mityugov <d.mityugov@postgrespro.ru>)
Ответы Re: [PATCH] Use strchr() to search for a single character
Список pgsql-hackers
On Wed, 23 Jul 2025 at 09:34, Dmitry Mityugov <d.mityugov@postgrespro.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



В списке pgsql-hackers по дате отправления: