Skip to content

Commit

Permalink
Auto merge of #134376 - jdonszelmann:fix-rustdoc-perf, r=jieyouxu
Browse files Browse the repository at this point in the history
Try to fix perf regression in rustdoc after hir attributes

Slight performance regression introduced in #131808

r? `@jieyouxu`
  • Loading branch information
bors committed Dec 17, 2024
2 parents a4cb3c8 + 62a2103 commit 7e6bf00
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions compiler/rustc_resolve/src/rustdoc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/clean/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 7e6bf00

Please sign in to comment.