Skip to content

Commit c975fe2

Browse files
torhovlandTor Hovland
authored and
Tor Hovland
committed
Put attrs in a Box for memory efficiency.
1 parent e2a77b3 commit c975fe2

File tree

3 files changed

+2
-4
lines changed

3 files changed

+2
-4
lines changed

src/librustdoc/clean/types.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2081,7 +2081,7 @@ crate enum ImportKind {
20812081
crate struct ImportSource {
20822082
crate path: Path,
20832083
crate did: Option<DefId>,
2084-
crate attrs: Option<Attributes>,
2084+
crate attrs: Option<Box<Attributes>>,
20852085
}
20862086

20872087
#[derive(Clone, Debug)]

src/librustdoc/clean/utils.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ crate fn register_res(cx: &mut DocContext<'_>, res: Res) -> DefId {
469469

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

474474
ImportSource { did, path, attrs }
475475
}

src/librustdoc/html/render/print_item.rs

-2
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,6 @@ fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[cl
285285
let (stab, stab_tags) = if let (Some(def_id), Some(attrs)) =
286286
(import.source.did, import.source.attrs.clone())
287287
{
288-
let attrs = Box::new(attrs);
289-
290288
// Just need an item with the correct def_id and attrs
291289
let import_item = clean::Item { def_id, attrs, ..myitem.clone() };
292290

0 commit comments

Comments
 (0)