Skip to content

Commit 1fda290

Browse files
committed
Don't create new vec for adding highlight range
1 parent 0084b64 commit 1fda290

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

crates/markdown_preview/src/markdown_parser.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -858,11 +858,10 @@ impl<'a> MarkdownParser<'a> {
858858
text: SharedString,
859859
highlights: Vec<MarkdownHighlight>,
860860
) -> Vec<(Range<usize>, MarkdownHighlight)> {
861-
let mut new_highlights = Vec::with_capacity(highlights.len());
862-
for style in highlights.iter() {
863-
new_highlights.push((0..text.len(), style.clone()));
864-
}
865-
new_highlights
861+
highlights
862+
.into_iter()
863+
.map(|style| (0..text.len(), style))
864+
.collect()
866865
}
867866

868867
match &node.data {

0 commit comments

Comments
 (0)