diff options
| author | bors <bors@rust-lang.org> | 2020-11-25 16:22:11 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-11-25 16:22:11 +0000 |
| commit | db79d2f63780613e700cb58b4339c48287555ae0 (patch) | |
| tree | 655a37779d20fff40846c0bc13134e9fee87d77a /compiler/rustc_incremental/src | |
| parent | 36018a4d062fe30f0817685cab7b7ee2f2a367a8 (diff) | |
| parent | d00ed018767f5ffb4d17971147fadeb860891f8d (diff) | |
| download | rust-db79d2f63780613e700cb58b4339c48287555ae0.tar.gz rust-db79d2f63780613e700cb58b4339c48287555ae0.zip | |
Auto merge of #79216 - Aaron1011:opt-on-disk-cache, r=pnkfelix
Only create `OnDiskCache` in incremental compilation mode This lets us skip doing useless work when we're not in incremental compilation mode.
Diffstat (limited to 'compiler/rustc_incremental/src')
| -rw-r--r-- | compiler/rustc_incremental/src/persist/load.rs | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/compiler/rustc_incremental/src/persist/load.rs b/compiler/rustc_incremental/src/persist/load.rs index 578c045a2b4..201f381f889 100644 --- a/compiler/rustc_incremental/src/persist/load.rs +++ b/compiler/rustc_incremental/src/persist/load.rs @@ -199,9 +199,14 @@ pub fn load_dep_graph(sess: &Session) -> DepGraphFuture { })) } -pub fn load_query_result_cache(sess: &Session) -> OnDiskCache<'_> { +/// Attempts to load the query result cache from disk +/// +/// If we are not in incremental compilation mode, returns `None`. +/// Otherwise, tries to load the query result cache from disk, +/// creating an empty cache if it could not be loaded. +pub fn load_query_result_cache(sess: &Session) -> Option<OnDiskCache<'_>> { if sess.opts.incremental.is_none() { - return OnDiskCache::new_empty(sess.source_map()); + return None; } let _prof_timer = sess.prof.generic_activity("incr_comp_load_query_result_cache"); @@ -211,7 +216,9 @@ pub fn load_query_result_cache(sess: &Session) -> OnDiskCache<'_> { &query_cache_path(sess), sess.is_nightly_build(), ) { - LoadResult::Ok { data: (bytes, start_pos) } => OnDiskCache::new(sess, bytes, start_pos), - _ => OnDiskCache::new_empty(sess.source_map()), + LoadResult::Ok { data: (bytes, start_pos) } => { + Some(OnDiskCache::new(sess, bytes, start_pos)) + } + _ => Some(OnDiskCache::new_empty(sess.source_map())), } } |
