On July 2, 2020 3:26:29 PM EDT, Tito <farmat...@tiscali.it> wrote:
>hi,
>just for fun I add my version:
>
>char* FAST_FUNC last_char_is(const char *s, int c)  {
>       while (s && *s && *(s + 1)) s++;
>       return (c == *s) ? (char *)s : NULL;
>}

That's pretty small, but it performs three comparisons for each character until 
the end and effectively scans the string twice in "parallel." If a bad pointer 
is passed in s, it'll segfault at the equality check in the return statement 
even though the first comparison is supposed to be a null pointer safeguard.
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to