Sujet : Re: Interval Comparisons
De : bc (at) *nospam* freeuk.com (bart)
Groupes : comp.lang.cDate : 04. Jun 2024, 17:54:33
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <v3ngs9$gksq$1@dont-email.me>
References : 1 2 3 4 5 6 7 8 9
User-Agent : Mozilla Thunderbird
On 04/06/2024 17:25, Michael S wrote:
On Tue, 4 Jun 2024 16:58:43 +0100
bart <bc@freeuk.com> wrote:
On 04/06/2024 16:27, Scott Lurndal wrote:
David Brown <david.brown@hesbynett.no> writes:
On 04/06/2024 13:23, bart wrote:
It is incredibly useful:
>
if c in [' ', '\t', '\n'] then ... # whitespace
>
if (strpbrk(c, " \t\n") != NULL) it_is_whitespace.
>
That doesn't do the same thing. In my example, c is a character, not
a string.
>
Will that be be better?
if (memchr(" \t\n", c, 3) != NULL)
It's a better match. But on gcc-O3, it still calls the library function up to version 12.x. After that, it's smart enough to generate similar code to my non-optimising compiler using the built-in feature.
It is also still limited to byte values.
My approach is to fix a language, which is easier, than to expend magnitudes more effort in elaborate tools and ultra-smart compilers.