Skip to content

Commit

Permalink
Put attrs in a Box for memory efficiency.
Browse files Browse the repository at this point in the history
  • Loading branch information
torhovland authored and Tor Hovland committed Apr 18, 2021
1 parent e2a77b3 commit c975fe2
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/librustdoc/clean/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2081,7 +2081,7 @@ crate enum ImportKind {
crate struct ImportSource {
crate path: Path,
crate did: Option<DefId>,
crate attrs: Option<Attributes>,
crate attrs: Option<Box<Attributes>>,
}

#[derive(Clone, Debug)]
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/clean/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ crate fn register_res(cx: &mut DocContext<'_>, res: Res) -> DefId {

crate fn resolve_use_source(cx: &mut DocContext<'_>, path: Path) -> ImportSource {
let did = if path.res.opt_def_id().is_none() { None } else { Some(register_res(cx, path.res)) };
let attrs = did.map(|did| cx.tcx.get_attrs(did).clean(cx));
let attrs = did.map(|did| Box::new(cx.tcx.get_attrs(did).clean(cx)));

ImportSource { did, path, attrs }
}
Expand Down
2 changes: 0 additions & 2 deletions src/librustdoc/html/render/print_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,6 @@ fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[cl
let (stab, stab_tags) = if let (Some(def_id), Some(attrs)) =
(import.source.did, import.source.attrs.clone())
{
let attrs = Box::new(attrs);

// Just need an item with the correct def_id and attrs
let import_item = clean::Item { def_id, attrs, ..myitem.clone() };

Expand Down

0 comments on commit c975fe2

Please sign in to comment.