diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2025-03-25 20:52:17 +1100 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2025-03-26 06:56:11 +1100 |
| commit | ffee55c18c19c551d58a6d68e1b3feb7618d0455 (patch) | |
| tree | ff36133677d1bfde97a48bb88a1712bd194a0fe9 /src/librustdoc/json/conversions.rs | |
| parent | aa8f0fd7163a2f23aa958faed30c9c2b77b934a5 (diff) | |
| download | rust-ffee55c18c19c551d58a6d68e1b3feb7618d0455.tar.gz rust-ffee55c18c19c551d58a6d68e1b3feb7618d0455.zip | |
rustdoc: Rearrange `Item`/`ItemInner`.
The `Item` struct is 48 bytes and contains a `Box<ItemInner>`; `ItemInner` is 104 bytes. This is an odd arrangement. Normally you'd have one of the following. - A single large struct, which avoids the allocation for the `Box`, but can result in lots of wasted space in unused parts of a container like `Vec<Item>`, `HashSet<Item>`, etc. - Or, something like `struct Item(Box<ItemInner>)`, which requires the `Box` allocation but gives a very small Item size, which is good for containers like `Vec<Item>`. `Item`/`ItemInner` currently gets the worst of both worlds: it always requires a `Box`, but `Item` is also pretty big and so wastes space in containers. It would make sense to push it in one direction or the other. #138916 showed that the first option is a regression for rustdoc, so this commit does the second option, which improves speed and reduces memory usage.
Diffstat (limited to 'src/librustdoc/json/conversions.rs')
| -rw-r--r-- | src/librustdoc/json/conversions.rs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/librustdoc/json/conversions.rs b/src/librustdoc/json/conversions.rs index a5351b350dd..9d8eb70fbe0 100644 --- a/src/librustdoc/json/conversions.rs +++ b/src/librustdoc/json/conversions.rs @@ -43,7 +43,7 @@ impl JsonRenderer<'_> { let attrs = item.attributes(self.tcx, self.cache(), true); let span = item.span(self.tcx); let visibility = item.visibility(self.tcx); - let clean::Item { name, item_id, .. } = item; + let clean::ItemInner { name, item_id, .. } = *item.inner; let id = self.id_from_item(&item); let inner = match item.kind { clean::KeywordItem => return None, |
