diff options
| author | bors <bors@rust-lang.org> | 2024-12-17 21:34:13 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-12-17 21:34:13 +0000 |
| commit | 7e6bf003f396aeea510577b4e925d1d95c12ff53 (patch) | |
| tree | 58986bb86721d206438e84fb09c3c52f910bc66e | |
| parent | a4cb3c831823d9baa56c3d90514b75b2660116fa (diff) | |
| parent | 62a21038ec15198a035dd5dd56e95fd40bf0e734 (diff) | |
| download | rust-7e6bf003f396aeea510577b4e925d1d95c12ff53.tar.gz rust-7e6bf003f396aeea510577b4e925d1d95c12ff53.zip | |
Auto merge of #134376 - jdonszelmann:fix-rustdoc-perf, r=jieyouxu
Try to fix perf regression in rustdoc after hir attributes Slight performance regression introduced in #131808 r? `@jieyouxu`
| -rw-r--r-- | compiler/rustc_resolve/src/rustdoc.rs | 5 | ||||
| -rw-r--r-- | src/librustdoc/clean/types.rs | 2 |
2 files changed, 4 insertions, 3 deletions
diff --git a/compiler/rustc_resolve/src/rustdoc.rs b/compiler/rustc_resolve/src/rustdoc.rs index ed421da0241..118e224675a 100644 --- a/compiler/rustc_resolve/src/rustdoc.rs +++ b/compiler/rustc_resolve/src/rustdoc.rs @@ -12,6 +12,7 @@ use rustc_middle::ty::TyCtxt; use rustc_span::def_id::DefId; use rustc_span::symbol::{Symbol, kw, sym}; use rustc_span::{DUMMY_SP, InnerSpan, Span}; +use thin_vec::ThinVec; use tracing::{debug, trace}; #[derive(Clone, Copy, PartialEq, Eq, Debug)] @@ -196,9 +197,9 @@ pub fn add_doc_fragment(out: &mut String, frag: &DocFragment) { pub fn attrs_to_doc_fragments<'a, A: AttributeExt + Clone + 'a>( attrs: impl Iterator<Item = (&'a A, Option<DefId>)>, doc_only: bool, -) -> (Vec<DocFragment>, Vec<A>) { +) -> (Vec<DocFragment>, ThinVec<A>) { let mut doc_fragments = Vec::new(); - let mut other_attrs = Vec::<A>::new(); + let mut other_attrs = ThinVec::<A>::new(); for (attr, item_id) in attrs { if let Some((doc_str, comment_kind)) = attr.doc_str_and_comment_kind() { let doc = beautify_doc_string(doc_str, comment_kind); diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index 0918a90d04b..64d99b1d226 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -1150,7 +1150,7 @@ pub struct RenderedLink { #[derive(Clone, Debug, Default)] pub(crate) struct Attributes { pub(crate) doc_strings: Vec<DocFragment>, - pub(crate) other_attrs: Vec<hir::Attribute>, + pub(crate) other_attrs: ThinVec<hir::Attribute>, } impl Attributes { |
