rust/library/alloc
bors a426fc37f2 Auto merge of #85391 - Mark-Simulacrum:opt-tostring, r=scottmcm
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!.
2021-05-20 00:55:27 +00:00
..
benches remove InPlaceIterable marker from Peekable due to unsoundness 2021-05-19 01:41:09 +02:00
src Auto merge of #85391 - Mark-Simulacrum:opt-tostring, r=scottmcm 2021-05-20 00:55:27 +00:00
tests from review: more robust test 2021-05-19 01:41:12 +02:00
Cargo.toml Add support for const operands and options to global_asm! 2021-05-13 22:31:57 +01:00