Remove a single allocation on doc lints (#16314)
Extremely small change, -0.018% performance improvement on `tokio` Just some warmup for continuing on larger optimizations (i.e. `nonminimal_bool`) changelog:Remove allocations via String pre-allocating.
This commit is contained in:
commit
bddcea71d0
1 changed files with 6 additions and 4 deletions
|
|
@ -869,10 +869,12 @@ fn check_attrs(cx: &LateContext<'_>, valid_idents: &FxHashSet<String>, attrs: &[
|
|||
}),
|
||||
true,
|
||||
);
|
||||
let mut doc = fragments.iter().fold(String::new(), |mut acc, fragment| {
|
||||
add_doc_fragment(&mut acc, fragment);
|
||||
acc
|
||||
});
|
||||
|
||||
let mut doc = String::with_capacity(fragments.iter().map(|frag| frag.doc.as_str().len() + 1).sum());
|
||||
|
||||
for fragment in &fragments {
|
||||
add_doc_fragment(&mut doc, fragment);
|
||||
}
|
||||
doc.pop();
|
||||
|
||||
if doc.trim().is_empty() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue