about summary refs log tree commit diff
diff options
context:
space:
mode:
authorCamelid <camelidcamel@gmail.com>2021-03-01 20:06:49 -0800
committerCamelid <camelidcamel@gmail.com>2021-03-05 20:01:52 -0800
commit5b7409797555b8fcfb50dc92fcda9bd1298d70c4 (patch)
tree93f4cc10b26dabd43aea3feb7d468579f2b4bbb6
parentc09d9d34f02c72b93da25ba27758db7d7cddb1f4 (diff)
downloadrust-5b7409797555b8fcfb50dc92fcda9bd1298d70c4.tar.gz
rust-5b7409797555b8fcfb50dc92fcda9bd1298d70c4.zip
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.
-rw-r--r--src/librustdoc/html/markdown/tests.rs1
-rw-r--r--src/librustdoc/html/render/context.rs14
2 files changed, 7 insertions, 8 deletions
diff --git a/src/librustdoc/html/markdown/tests.rs b/src/librustdoc/html/markdown/tests.rs
index e016d2c3ab0..e2ce9ad23f4 100644
--- a/src/librustdoc/html/markdown/tests.rs
+++ b/src/librustdoc/html/markdown/tests.rs
@@ -1,7 +1,6 @@
 use super::{plain_text_summary, short_markdown_summary};
 use super::{ErrorCodes, IdMap, Ignore, LangString, Markdown, MarkdownHtml};
 use rustc_span::edition::{Edition, DEFAULT_EDITION};
-use std::cell::RefCell;
 
 #[test]
 fn test_unique_id() {
diff --git a/src/librustdoc/html/render/context.rs b/src/librustdoc/html/render/context.rs
index 41d4aef7c7a..864fbccbcc4 100644
--- a/src/librustdoc/html/render/context.rs
+++ b/src/librustdoc/html/render/context.rs
@@ -52,10 +52,10 @@ crate struct Context<'tcx> {
     /// publicly reused items to redirect to the right location.
     pub(super) render_redirect_pages: bool,
     /// The map used to ensure all generated 'id=' attributes are unique.
-    pub(super) id_map: Box<RefCell<IdMap>>,
+    pub(super) id_map: RefCell<IdMap>,
     /// Tracks section IDs for `Deref` targets so they match in both the main
     /// body and the sidebar.
-    pub(super) deref_id_map: Box<RefCell<FxHashMap<DefId, String>>>,
+    pub(super) deref_id_map: RefCell<FxHashMap<DefId, String>>,
     /// Shared mutable state.
     ///
     /// Issue for improving the situation: [#82381][]
@@ -76,7 +76,7 @@ crate struct Context<'tcx> {
 
 // `Context` is cloned a lot, so we don't want the size to grow unexpectedly.
 #[cfg(target_arch = "x86_64")]
-rustc_data_structures::static_assert_size!(Context<'_>, 88);
+rustc_data_structures::static_assert_size!(Context<'_>, 152);
 
 impl<'tcx> Context<'tcx> {
     pub(super) fn path(&self, filename: &str) -> PathBuf {
@@ -415,8 +415,8 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
             current: Vec::new(),
             dst,
             render_redirect_pages: false,
-            id_map: Box::new(RefCell::new(id_map)),
-            deref_id_map: Box::new(RefCell::new(FxHashMap::default())),
+            id_map: RefCell::new(id_map),
+            deref_id_map: RefCell::new(FxHashMap::default()),
             shared: Rc::new(scx),
             cache: Rc::new(cache),
         };
@@ -438,8 +438,8 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
             current: self.current.clone(),
             dst: self.dst.clone(),
             render_redirect_pages: self.render_redirect_pages,
-            id_map: Box::new(RefCell::new(id_map)),
-            deref_id_map: Box::new(RefCell::new(FxHashMap::default())),
+            id_map: RefCell::new(id_map),
+            deref_id_map: RefCell::new(FxHashMap::default()),
             shared: Rc::clone(&self.shared),
             cache: Rc::clone(&self.cache),
         }