mirror of
https://github.com/tokio-rs/tracing.git
synced 2025-10-01 23:10:31 +00:00
subscriber: use Formatter::write_char
rather than pad
This commit replaces uses of `Formatter::pad` with `Formatter::write_char` wherever a single character is written to a formatter. This prevents us from inadvertantly padding these characters incorrectly, and may avoid some overhead. Signed-off-by: Eliza Weisman <eliza@buoyant.io>
This commit is contained in:
parent
f079f2d06a
commit
d92342e35c
@ -516,7 +516,7 @@ where
|
||||
})?;
|
||||
|
||||
if seen {
|
||||
f.pad(" ")?;
|
||||
f.write_char(' ')?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@ -548,13 +548,13 @@ where
|
||||
}
|
||||
|
||||
fn bold(&self) -> Style {
|
||||
#[cfg(feature = "ansi")] {
|
||||
#[cfg(feature = "ansi")]
|
||||
{
|
||||
if self.ansi {
|
||||
return Style::new().bold();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Style::new()
|
||||
}
|
||||
}
|
||||
@ -579,11 +579,11 @@ where
|
||||
if !fields.is_empty() {
|
||||
write!(f, "{}{}{}", bold.paint("{"), fields, bold.paint("}"))?;
|
||||
}
|
||||
f.pad(":")
|
||||
f.write_char(':')
|
||||
})?;
|
||||
|
||||
if seen {
|
||||
f.pad(" ")?;
|
||||
f.write_char(' ')?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@ -594,7 +594,9 @@ struct Style;
|
||||
|
||||
#[cfg(not(feature = "ansi"))]
|
||||
impl Style {
|
||||
fn new() -> Self { Style }
|
||||
fn new() -> Self {
|
||||
Style
|
||||
}
|
||||
fn paint(&self, d: impl fmt::Display) -> impl fmt::Display {
|
||||
d
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user