1
Fork 0

Box ItemKind to reduce the size of Item

This brings the size of `Item` from

```
[src/librustdoc/lib.rs:103] std::mem::size_of::<Item>() = 680
```

to

```
[src/librustdoc/lib.rs:103] std::mem::size_of::<Item>() = 280
```
This commit is contained in:
Joshua Nelson 2020-12-13 11:32:57 -05:00
parent 3ffea60dd5
commit 4a4426377e
20 changed files with 90 additions and 94 deletions

View file

@ -19,9 +19,9 @@ impl JsonRenderer<'_> {
let item_type = ItemType::from(&item);
let deprecation = item.deprecation(self.tcx);
let clean::Item { source, name, attrs, kind, visibility, def_id } = item;
match kind {
match *kind {
clean::StrippedItem(_) => None,
_ => Some(Item {
kind => Some(Item {
id: def_id.into(),
crate_id: def_id.krate.as_u32(),
name: name.map(|sym| sym.to_string()),