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

Dmitry Mityugov <d.mityugov@postgrespro.ru>

From: Dmitry Mityugov <d.mityugov@postgrespro.ru>
To: pgsql-hackers@postgresql.org
Date: 2025-07-20T22:21:38Z
Lists: pgsql-hackers

Attachments

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 search for exactly one character in a string. In 
addition, if 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,
Dmitry

Commits

  1. Use strchr instead of strstr for single-char lookups