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:
Eliza Weisman 2020-02-03 12:41:27 -08:00
parent f079f2d06a
commit d92342e35c

View File

@ -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
}