Ushering out strlcpy()
Ushering out strlcpy()
Posted Aug 26, 2022 22:00 UTC (Fri) by NYKevin (subscriber, #129325)In reply to: Ushering out strlcpy() by wtarreau
Parent article: Ushering out strlcpy()
Well, sure, but you wouldn't write that loop (in Rust) in the first place. You'd call str::find[1] with suitable arguments, and then it's the implementation's problem to emit the most efficient way to do this. Since one possible set of arguments to str::find can be statically proven to be exactly equivalent to strchr (purely in terms of the type system, so this can be done in the monomorphization pass), the implementation should emit strchr if it is optimal to do so. If the implementation does not in fact emit strchr, and you think this is suboptimal, then you should file a bug with them. But don't tell me it's impossible. It's clearly possible.
[1]: https://doc.rust-lang.org/std/primitive.str.html#method.find
