Skip to content

Commit

Permalink
Reserve string buffer in PatternFormatter::format for performance
Browse files Browse the repository at this point in the history
  • Loading branch information
SpriteOvO committed Aug 16, 2024
1 parent 294f71c commit bf30def
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions spdlog/src/formatter/pattern_formatter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,12 @@ where
dest: &mut StringBuf,
ctx: &mut FormatterContext,
) -> crate::Result<()> {
cfg_if::cfg_if! {
if #[cfg(not(feature = "flexible-string"))] {
dest.reserve(crate::string_buf::RESERVE_SIZE);
}
};

let mut ctx = PatternContext::new(ctx);
self.pattern.format(record, dest, &mut ctx)?;
Ok(())
Expand Down

0 comments on commit bf30def

Please sign in to comment.