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