From 62a21038ec15198a035dd5dd56e95fd40bf0e734 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonathan=20D=C3=B6nszelmann?= Date: Mon, 16 Dec 2024 09:15:58 +0100 Subject: [PATCH] try fix hir-attrs perf --- compiler/rustc_resolve/src/rustdoc.rs | 5 +++-- 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 8b14fe31d8c50..bc0354fc3a800 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)>, doc_only: bool, -) -> (Vec, Vec) { +) -> (Vec, ThinVec) { let mut doc_fragments = Vec::new(); - let mut other_attrs = Vec::::new(); + let mut other_attrs = ThinVec::::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 d4dc35b6c9c8c..13b6f0e566ee3 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, - pub(crate) other_attrs: Vec, + pub(crate) other_attrs: ThinVec, } impl Attributes {