From: | Corey Huinker <corey(dot)huinker(at)gmail(dot)com> |
---|---|
To: | Dmitry Mityugov <d(dot)mityugov(at)postgrespro(dot)ru> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: [PATCH] Use strchr() to search for a single character |
Date: | 2025-07-22 19:42:42 |
Message-ID: | CADkLM=eZe5qp+_6ZifQhxYtvhYOTr-AydsWvXhPe2mZs=9npTw@mail.gmail.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Sun, Jul 20, 2025 at 6:21 PM Dmitry Mityugov <d(dot)mityugov(at)postgrespro(dot)ru>
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 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
Seems like a simple-enough change, not a huge win but probably worth doing.
Using ripgrep to search for 'strstr(.*".")' turns up two similar situations
in contrib/fuzzystrmatch/dmetaphone.c, so perhaps we include those.
There's also a match in src/bin/pg_rewind/filemap.c, but that one is a
false positive.
From | Date | Subject | |
---|---|---|---|
Next Message | Sami Imseih | 2025-07-22 19:52:49 | Re: track generic and custom plans in pg_stat_statements |
Previous Message | Nathan Bossart | 2025-07-22 19:25:13 | Re: Verify predefined LWLocks tranches have entries in wait_event_names.txt |