Skip to content

Commit 6ba46c3

Browse files
committed
Reserve string buffer in PatternFormatter::format for performance
1 parent b0f810f commit 6ba46c3

File tree

1 file changed

+6
-0
lines changed
  • spdlog/src/formatter/pattern_formatter

1 file changed

+6
-0
lines changed

spdlog/src/formatter/pattern_formatter/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,12 @@ where
375375
dest: &mut StringBuf,
376376
fmt_ctx: &mut FormatterContext,
377377
) -> crate::Result<()> {
378+
cfg_if::cfg_if! {
379+
if #[cfg(not(feature = "flexible-string"))] {
380+
dest.reserve(crate::string_buf::RESERVE_SIZE);
381+
}
382+
};
383+
378384
let mut pat_ctx = PatternContext::new(fmt_ctx);
379385
self.pattern.format(record, dest, &mut pat_ctx)?;
380386
Ok(())

0 commit comments

Comments
 (0)