Skip to content

Commit ff39c46

Browse files
committed
Box some fields to reduce Context size
Reduced from 152 bytes to 88 bytes.
1 parent 4c51a66 commit ff39c46

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/librustdoc/html/render/context.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ crate struct Context<'tcx> {
5353
/// publicly reused items to redirect to the right location.
5454
pub(super) render_redirect_pages: bool,
5555
/// The map used to ensure all generated 'id=' attributes are unique.
56-
pub(super) id_map: RefCell<IdMap>,
56+
pub(super) id_map: Box<RefCell<IdMap>>,
5757
/// Tracks section IDs for `Deref` targets so they match in both the main
5858
/// body and the sidebar.
59-
pub(super) deref_id_map: RefCell<FxHashMap<DefId, String>>,
59+
pub(super) deref_id_map: Box<RefCell<FxHashMap<DefId, String>>>,
6060
/// Shared mutable state.
6161
///
6262
/// Issue for improving the situation: [#82381][]
@@ -77,7 +77,7 @@ crate struct Context<'tcx> {
7777

7878
// `Context` is cloned a lot, so we don't want the size to grow unexpectedly.
7979
#[cfg(target_arch = "x86_64")]
80-
rustc_data_structures::static_assert_size!(Context<'_>, 152);
80+
rustc_data_structures::static_assert_size!(Context<'_>, 88);
8181

8282
impl<'tcx> Context<'tcx> {
8383
pub(super) fn path(&self, filename: &str) -> PathBuf {
@@ -421,8 +421,8 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
421421
current: Vec::new(),
422422
dst,
423423
render_redirect_pages: false,
424-
id_map: RefCell::new(id_map),
425-
deref_id_map: RefCell::new(FxHashMap::default()),
424+
id_map: Box::new(RefCell::new(id_map)),
425+
deref_id_map: Box::new(RefCell::new(FxHashMap::default())),
426426
shared: Rc::new(scx),
427427
cache: Rc::new(cache),
428428
};

0 commit comments

Comments
 (0)