I've said it before: there should only be one str* function in the standard lib: `strnlen`, and it should only be used to implement safer \
@stephentyrone Don't you mean memchr? It can be used to implement strnlen but also "strnchr", etc.
-
-
@RichFelker You need `memcchr` for (single pass) `strnchr`, but yeah. `memchr` / `strnlen` are equivalent to me. -
@RichFelker Exposing `strnlen` is basically my concession to people who wouldn't be able to figure out how to use `memchr`.
End of conversation
New conversation -
-
-
@stephentyrone And don't forget strstr which has no easy substitute, although of course strnstr would be preferable. -
@RichFelker `strstr` is horrific. If strings are short, you're better off using stupid algorithm. If long, you want the length anyway. -
@RichFelker So you really want to know the string lengths to choose code path; given that you'll almost certainly perform some other string -
@RichFelker operation, the cost of computing the length can be effectively amortized. -
@RichFelker Can one construct microbenchmark of small unrelated strstrs? Of course. Who cares?
End of conversation
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.