about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2014-05-27 17:15:10 -0700
committerAlex Crichton <alex@alexcrichton.com>2014-05-31 21:59:50 -0700
commit0777ce86e1adc55362e1190db7b74e8f29559b3d (patch)
treed49ec6714b0fc58b2866cea10748eeab5b3776f9
parent356423d8f1c308f0dc77f803f8ed00c7e80305f3 (diff)
downloadrust-0777ce86e1adc55362e1190db7b74e8f29559b3d.tar.gz
rust-0777ce86e1adc55362e1190db7b74e8f29559b3d.zip
rustdoc: Freeze the cache ASAP
The cache is going to be used earlier in the HTML generation process, which
means that it needs to get into TLS as soon as possible.
-rw-r--r--src/librustdoc/html/render.rs15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs
index 7f1e42ce602..ab985828a46 100644
--- a/src/librustdoc/html/render.rs
+++ b/src/librustdoc/html/render.rs
@@ -307,11 +307,17 @@ pub fn run(mut krate: clean::Crate, dst: Path) -> io::IoResult<()> {
     }
 
     let index = try!(build_index(&krate, &mut cache));
-    try!(write_shared(&cx, &krate, &cache, index));
+
+    // Freeze the cache now that the index has been built. Put an Arc into TLS
+    // for future parallelization opportunities
+    let cache = Arc::new(cache);
+    cache_key.replace(Some(cache.clone()));
+
+    try!(write_shared(&cx, &krate, &*cache, index));
     let krate = try!(render_sources(&mut cx, krate));
 
     // And finally render the whole crate's documentation
-    cx.krate(krate, cache)
+    cx.krate(krate)
 }
 
 fn build_index(krate: &clean::Crate, cache: &mut Cache) -> io::IoResult<String> {
@@ -954,16 +960,13 @@ impl Context {
     ///
     /// This currently isn't parallelized, but it'd be pretty easy to add
     /// parallelization to this function.
-    fn krate(self, mut krate: clean::Crate, cache: Cache) -> io::IoResult<()> {
+    fn krate(self, mut krate: clean::Crate) -> io::IoResult<()> {
         let mut item = match krate.module.take() {
             Some(i) => i,
             None => return Ok(())
         };
         item.name = Some(krate.name);
 
-        // using a rwarc makes this parallelizable in the future
-        cache_key.replace(Some(Arc::new(cache)));
-
         let mut work = vec!((self, item));
         loop {
             match work.pop() {