Skip to content

Commit 6e1b9bd

Browse files
committed
Auto merge of rust-lang#134376 - jdonszelmann:fix-rustdoc-perf, r=jieyouxu
Try to fix perf regression in rustdoc after hir attributes Slight performance regression introduced in rust-lang#131808 r? `@jieyouxu`
2 parents f23a80a + 62a2103 commit 6e1b9bd

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

compiler/rustc_resolve/src/rustdoc.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use rustc_middle::ty::TyCtxt;
1212
use rustc_span::def_id::DefId;
1313
use rustc_span::symbol::{Symbol, kw, sym};
1414
use rustc_span::{DUMMY_SP, InnerSpan, Span};
15+
use thin_vec::ThinVec;
1516
use tracing::{debug, trace};
1617

1718
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
@@ -196,9 +197,9 @@ pub fn add_doc_fragment(out: &mut String, frag: &DocFragment) {
196197
pub fn attrs_to_doc_fragments<'a, A: AttributeExt + Clone + 'a>(
197198
attrs: impl Iterator<Item = (&'a A, Option<DefId>)>,
198199
doc_only: bool,
199-
) -> (Vec<DocFragment>, Vec<A>) {
200+
) -> (Vec<DocFragment>, ThinVec<A>) {
200201
let mut doc_fragments = Vec::new();
201-
let mut other_attrs = Vec::<A>::new();
202+
let mut other_attrs = ThinVec::<A>::new();
202203
for (attr, item_id) in attrs {
203204
if let Some((doc_str, comment_kind)) = attr.doc_str_and_comment_kind() {
204205
let doc = beautify_doc_string(doc_str, comment_kind);

src/librustdoc/clean/types.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1150,7 +1150,7 @@ pub struct RenderedLink {
11501150
#[derive(Clone, Debug, Default)]
11511151
pub(crate) struct Attributes {
11521152
pub(crate) doc_strings: Vec<DocFragment>,
1153-
pub(crate) other_attrs: Vec<hir::Attribute>,
1153+
pub(crate) other_attrs: ThinVec<hir::Attribute>,
11541154
}
11551155

11561156
impl Attributes {

0 commit comments

Comments
 (0)