about summary refs log tree commit diff
diff options
context:
space:
mode:
authorWaqar Ahmed <waqar.17a@gmail.com>2023-12-19 11:22:02 +0500
committerWaqar Ahmed <waqar.17a@gmail.com>2023-12-19 11:22:02 +0500
commit13177e314db089fae780bcdb936d8a5ac3d62479 (patch)
treee4910573018119fcb6b79add5dec317af2bcef9f
parent0ed815faca2c408803cb2724c288ca8a2094e58b (diff)
downloadrust-13177e314db089fae780bcdb936d8a5ac3d62479.tar.gz
rust-13177e314db089fae780bcdb936d8a5ac3d62479.zip
minor: Use reserve when removing markdown from text
After markdown syntax removal the length of the text is roughly the
same so we can reserve memory beforehand
-rw-r--r--crates/ide/src/markdown_remove.rs1
1 files changed, 1 insertions, 0 deletions
diff --git a/crates/ide/src/markdown_remove.rs b/crates/ide/src/markdown_remove.rs
index 718868c8747..26449f4a2c5 100644
--- a/crates/ide/src/markdown_remove.rs
+++ b/crates/ide/src/markdown_remove.rs
@@ -6,6 +6,7 @@ use pulldown_cmark::{Event, Parser, Tag};
 /// Currently limited in styling, i.e. no ascii tables or lists
 pub(crate) fn remove_markdown(markdown: &str) -> String {
     let mut out = String::new();
+    out.reserve_exact(markdown.len());
     let parser = Parser::new(markdown);
 
     for event in parser {