Hi Bruno,

On 2026-02-21T16:23:28+0100, Bruno Haible wrote:
> Alejandro Colomar wrote:
> > > strchr is a red herring, because this way to define strnul is compiled
> > > less efficiently than (s + strlen (s)). See attached example code.
> > 
> > Not really.  At -O1, both GCC and Clang produce the same exact code:
> 
> Not all versions of GCC and clang do so. See the comments in the
> file 'foo.c' that I had attached.

Hmmm.  GCC 7 is ~9 years ago.  I think we could live with that.
Especially, since it simplifies the source code by orders of magnitude.

Another issue I have with the version you've pushed is that the function
seems to return a const-qualified pointer, which means that you can't
use it as a callback that works on non-const pointers.


Have a lovely day!
Alex

-- 
<https://www.alejandro-colomar.es>

Attachment: signature.asc
Description: PGP signature

Reply via email to