Skip to content

Commit 32a216e

Browse files
authored
Reuse previous Vec allocation in loop (#15428)
Minor optimization to avoid deallocating/reallocating a new `Vec` in the top `check_doc` loop. changelog: none r? blyxyas
2 parents 334fb90 + cece1b9 commit 32a216e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

clippy_lints/src/doc/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,12 +1139,12 @@ fn check_doc<'a, Events: Iterator<Item = (pulldown_cmark::Event<'a>, Range<usize
11391139
None,
11401140
"a backtick may be missing a pair",
11411141
);
1142+
text_to_check.clear();
11421143
} else {
1143-
for (text, range, assoc_code_level) in text_to_check {
1144+
for (text, range, assoc_code_level) in text_to_check.drain(..) {
11441145
markdown::check(cx, valid_idents, &text, &fragments, range, assoc_code_level, blockquote_level);
11451146
}
11461147
}
1147-
text_to_check = Vec::new();
11481148
},
11491149
Start(FootnoteDefinition(..)) => in_footnote_definition = true,
11501150
End(TagEnd::FootnoteDefinition) => in_footnote_definition = false,

0 commit comments

Comments
 (0)