Skip to content

Commit d92342e

Browse files
committed
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 <[email protected]>
1 parent f079f2d commit d92342e

File tree

1 file changed

+8
-6
lines changed
  • tracing-subscriber/src/fmt/format

1 file changed

+8
-6
lines changed

tracing-subscriber/src/fmt/format/mod.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ where
516516
})?;
517517

518518
if seen {
519-
f.pad(" ")?;
519+
f.write_char(' ')?;
520520
}
521521
Ok(())
522522
}
@@ -548,13 +548,13 @@ where
548548
}
549549

550550
fn bold(&self) -> Style {
551-
#[cfg(feature = "ansi")] {
551+
#[cfg(feature = "ansi")]
552+
{
552553
if self.ansi {
553554
return Style::new().bold();
554555
}
555556
}
556557

557-
558558
Style::new()
559559
}
560560
}
@@ -579,11 +579,11 @@ where
579579
if !fields.is_empty() {
580580
write!(f, "{}{}{}", bold.paint("{"), fields, bold.paint("}"))?;
581581
}
582-
f.pad(":")
582+
f.write_char(':')
583583
})?;
584584

585585
if seen {
586-
f.pad(" ")?;
586+
f.write_char(' ')?;
587587
}
588588
Ok(())
589589
}
@@ -594,7 +594,9 @@ struct Style;
594594

595595
#[cfg(not(feature = "ansi"))]
596596
impl Style {
597-
fn new() -> Self { Style }
597+
fn new() -> Self {
598+
Style
599+
}
598600
fn paint(&self, d: impl fmt::Display) -> impl fmt::Display {
599601
d
600602
}

0 commit comments

Comments
 (0)