mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-28 09:44:08 +00:00
a426fc37f2
Avoid zero-length memcpy in formatting This has two separate and somewhat orthogonal commits. The first change adjusts the ToString general impl for all types that implement Display; it no longer uses the full format machinery, rather directly falling onto a `std::fmt::Display::fmt` call. The second change directly adjusts the general core::fmt::write function which handles the production of format_args! to avoid zero-length push_str calls. Both changes target the fact that push_str will still call memmove internally (or a similar function), as it doesn't know the length of the passed string. For zero-length strings in particular, this is quite expensive, and even for very short (several bytes long) strings, this is also expensive. Future work in this area may wish to have us fallback to write_char or similar, which may be cheaper on the (typically) short strings between the interpolated pieces in format_args!. |
||
---|---|---|
.. | ||
benches | ||
src | ||
tests | ||
Cargo.toml |