Skip to content

Commit 5b74097

Browse files
committed
Undo addition of boxes
I don't think the boxing helped performance, in fact I think it potentially made it worse. The data was still being copied, but now it was through a pointer. Thinking about it more, I think boxing might only help when you're passing a big object around by value all the time, rather than the slowdown being that you're cloning it.
1 parent c09d9d3 commit 5b74097

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

src/librustdoc/html/markdown/tests.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use super::{plain_text_summary, short_markdown_summary};
22
use super::{ErrorCodes, IdMap, Ignore, LangString, Markdown, MarkdownHtml};
33
use rustc_span::edition::{Edition, DEFAULT_EDITION};
4-
use std::cell::RefCell;
54

65
#[test]
76
fn test_unique_id() {

src/librustdoc/html/render/context.rs

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

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

8181
impl<'tcx> Context<'tcx> {
8282
pub(super) fn path(&self, filename: &str) -> PathBuf {
@@ -415,8 +415,8 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
415415
current: Vec::new(),
416416
dst,
417417
render_redirect_pages: false,
418-
id_map: Box::new(RefCell::new(id_map)),
419-
deref_id_map: Box::new(RefCell::new(FxHashMap::default())),
418+
id_map: RefCell::new(id_map),
419+
deref_id_map: RefCell::new(FxHashMap::default()),
420420
shared: Rc::new(scx),
421421
cache: Rc::new(cache),
422422
};
@@ -438,8 +438,8 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
438438
current: self.current.clone(),
439439
dst: self.dst.clone(),
440440
render_redirect_pages: self.render_redirect_pages,
441-
id_map: Box::new(RefCell::new(id_map)),
442-
deref_id_map: Box::new(RefCell::new(FxHashMap::default())),
441+
id_map: RefCell::new(id_map),
442+
deref_id_map: RefCell::new(FxHashMap::default()),
443443
shared: Rc::clone(&self.shared),
444444
cache: Rc::clone(&self.cache),
445445
}

0 commit comments

Comments
 (0)