Use less allocations in recording Display and Error values#1988
Use less allocations in recording Display and Error values#1988hawkw merged 2 commits intotokio-rs:masterfrom
Display and Error values#1988Conversation
Use the fact that the `Debug` implementation of `DisplayValue` corresponds to the `Display` implementation of the wrapped type. This means that the string allocation of the `Display`ed type can be avoided entirely.
|
I don't believe this actually avoids any allocations, as But, avoiding the macros is a bit nicer when they're not necessary, so I would be fine making this change. |
|
You're right, I was thinking of |
We can change the commit message when we merge + squash—don't worry about that. |
hawkw
left a comment
There was a problem hiding this comment.
Going to go ahead and merge this --- although it doesn't actually reduce allocations, I think it's a bit nicer to avoid the unnecessary use of format_args! macros.
|
huh, seems like the nightly compiler ICEs on this PR for some reason --- i wonder if that happens on main, too? https://github.com/tokio-rs/tracing/runs/5573114704?check_suite_focus=true |
|
@hawkw Current nightly is broken, CI runs also fail on other repos with that ICE. |
This branch removes some unnecessary uses of the `format_args!` and `write!` macros in `tracing-core`. Using `fmt::Display::fmt` and similar rather than the macros may be slightly more efficient. Co-authored-by: David Barsky <me@davidbarsky.com>
This branch removes some unnecessary uses of the `format_args!` and `write!` macros in `tracing-core`. Using `fmt::Display::fmt` and similar rather than the macros may be slightly more efficient. Co-authored-by: David Barsky <me@davidbarsky.com>
# 0.1.24 (April 1, 2022) This release fixes a bug where setting `NoSubscriber` as the local default would not locally disable the current global default subscriber. ### Fixed - Setting `NoSubscriber` as the local default now correctly disables the global default subscriber ([#2001]) - Fixed compilation warnings with the "std" feature disabled ([#2022]) ### Changed - Removed unnecessary use of `write!` and `format_args!` macros ([#1988]) [#1988]: #1988 [#2001]: #2001 [#2022]: #2022
# 0.1.24 (April 1, 2022) This release fixes a bug where setting `NoSubscriber` as the local default would not locally disable the current global default subscriber. ### Fixed - Setting `NoSubscriber` as the local default now correctly disables the global default subscriber ([#2001]) - Fixed compilation warnings with the "std" feature disabled ([#2022]) ### Changed - Removed unnecessary use of `write!` and `format_args!` macros ([#1988]) [#1988]: #1988 [#2001]: #2001 [#2022]: #2022
# 0.1.24 (April 1, 2022) This release fixes a bug where setting `NoSubscriber` as the local default would not locally disable the current global default subscriber. ### Fixed - Setting `NoSubscriber` as the local default now correctly disables the global default subscriber ([tokio-rs#2001]) - Fixed compilation warnings with the "std" feature disabled ([tokio-rs#2022]) ### Changed - Removed unnecessary use of `write!` and `format_args!` macros ([tokio-rs#1988]) [tokio-rs#1988]: tokio-rs#1988 [tokio-rs#2001]: tokio-rs#2001 [tokio-rs#2022]: tokio-rs#2022
Use the fact that the
Debugimplementation ofDisplayValuecorresponds to the
Displayimplementation of the wrapped type. Thismeans that the string allocation of the
Displayed type can be avoidedentirely.