mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-04 19:29:07 +00:00
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.
This commit is contained in:
parent
356423d8f1
commit
0777ce86e1
@ -307,11 +307,17 @@ pub fn run(mut krate: clean::Crate, dst: Path) -> io::IoResult<()> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let index = try!(build_index(&krate, &mut cache));
|
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));
|
let krate = try!(render_sources(&mut cx, krate));
|
||||||
|
|
||||||
// And finally render the whole crate's documentation
|
// 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> {
|
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
|
/// This currently isn't parallelized, but it'd be pretty easy to add
|
||||||
/// parallelization to this function.
|
/// 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() {
|
let mut item = match krate.module.take() {
|
||||||
Some(i) => i,
|
Some(i) => i,
|
||||||
None => return Ok(())
|
None => return Ok(())
|
||||||
};
|
};
|
||||||
item.name = Some(krate.name);
|
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));
|
let mut work = vec!((self, item));
|
||||||
loop {
|
loop {
|
||||||
match work.pop() {
|
match work.pop() {
|
||||||
|
Loading…
Reference in New Issue
Block a user