Skip to content

Commit 690aeaf

Browse files
committed
Box Item::attributes
This reduces the size of Item from 136 to 48 bytes.
1 parent fd34606 commit 690aeaf

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

src/librustdoc/clean/inline.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ crate fn try_inline(
121121
};
122122

123123
let target_attrs = load_attrs(cx, did);
124-
let attrs = merge_attrs(cx, Some(parent_module), target_attrs, attrs_clone);
124+
let attrs = box merge_attrs(cx, Some(parent_module), target_attrs, attrs_clone);
125125

126126
cx.renderinfo.borrow_mut().inlined.insert(did);
127127
let what_rustc_thinks = clean::Item::from_def_id_and_parts(did, Some(name), kind, cx);
@@ -444,7 +444,7 @@ crate fn build_impl(
444444
}),
445445
cx,
446446
);
447-
item.attrs = merge_attrs(cx, parent_module.into(), load_attrs(cx, did), attrs);
447+
item.attrs = box merge_attrs(cx, parent_module.into(), load_attrs(cx, did), attrs);
448448
debug!("merged_attrs={:?}", item.attrs);
449449
ret.push(item);
450450
}
@@ -466,7 +466,7 @@ fn build_module(cx: &DocContext<'_>, did: DefId, visited: &mut FxHashSet<DefId>)
466466
// Primitive types can't be inlined so generate an import instead.
467467
items.push(clean::Item {
468468
name: None,
469-
attrs: clean::Attributes::default(),
469+
attrs: box clean::Attributes::default(),
470470
source: clean::Span::dummy(),
471471
def_id: DefId::local(CRATE_DEF_INDEX),
472472
visibility: clean::Public,

src/librustdoc/clean/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -2169,7 +2169,7 @@ fn clean_extern_crate(
21692169
// FIXME: using `from_def_id_and_kind` breaks `rustdoc/masked` for some reason
21702170
vec![Item {
21712171
name: None,
2172-
attrs: krate.attrs.clean(cx),
2172+
attrs: box krate.attrs.clean(cx),
21732173
source: krate.span.clean(cx),
21742174
def_id: crate_def_id,
21752175
visibility: krate.vis.clean(cx),
@@ -2251,7 +2251,7 @@ impl Clean<Vec<Item>> for doctree::Import<'_> {
22512251
) {
22522252
items.push(Item {
22532253
name: None,
2254-
attrs: self.attrs.clean(cx),
2254+
attrs: box self.attrs.clean(cx),
22552255
source: self.span.clean(cx),
22562256
def_id: cx.tcx.hir().local_def_id(self.id).to_def_id(),
22572257
visibility: self.vis.clean(cx),
@@ -2269,7 +2269,7 @@ impl Clean<Vec<Item>> for doctree::Import<'_> {
22692269

22702270
vec![Item {
22712271
name: None,
2272-
attrs: self.attrs.clean(cx),
2272+
attrs: box self.attrs.clean(cx),
22732273
source: self.span.clean(cx),
22742274
def_id: cx.tcx.hir().local_def_id(self.id).to_def_id(),
22752275
visibility: self.vis.clean(cx),

src/librustdoc/clean/types.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,15 @@ crate struct Item {
8282
crate source: Span,
8383
/// Not everything has a name. E.g., impls
8484
crate name: Option<Symbol>,
85-
crate attrs: Attributes,
85+
crate attrs: Box<Attributes>,
8686
crate visibility: Visibility,
8787
crate kind: Box<ItemKind>,
8888
crate def_id: DefId,
8989
}
9090

9191
// `Item` is used a lot. Make sure it doesn't unintentionally get bigger.
9292
#[cfg(target_arch = "x86_64")]
93-
rustc_data_structures::static_assert_size!(Item, 136);
93+
rustc_data_structures::static_assert_size!(Item, 48);
9494

9595
impl fmt::Debug for Item {
9696
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
@@ -159,7 +159,7 @@ impl Item {
159159
kind: box kind,
160160
name,
161161
source: source.clean(cx),
162-
attrs: cx.tcx.get_attrs(def_id).clean(cx),
162+
attrs: box cx.tcx.get_attrs(def_id).clean(cx),
163163
visibility: cx.tcx.visibility(def_id).clean(cx),
164164
}
165165
}

0 commit comments

Comments
 (0)