diff options
| author | John Kåre Alsaker <john.kare.alsaker@gmail.com> | 2023-03-25 03:12:41 +0100 |
|---|---|---|
| committer | John Kåre Alsaker <john.kare.alsaker@gmail.com> | 2023-03-25 03:12:41 +0100 |
| commit | afe4c16b294312b7aeb920e9a988a3eaca580d3b (patch) | |
| tree | 329a5508558d2b262dbd8558efd8e12835cd5e48 | |
| parent | dfae9c993dc6ab685bc63c684c1ce66dfa596809 (diff) | |
| download | rust-afe4c16b294312b7aeb920e9a988a3eaca580d3b.tar.gz rust-afe4c16b294312b7aeb920e9a988a3eaca580d3b.zip | |
Split the `if` to release the lock earlier
| -rw-r--r-- | compiler/rustc_query_system/src/dep_graph/graph.rs | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/compiler/rustc_query_system/src/dep_graph/graph.rs b/compiler/rustc_query_system/src/dep_graph/graph.rs index 09b85010666..80618fd1abe 100644 --- a/compiler/rustc_query_system/src/dep_graph/graph.rs +++ b/compiler/rustc_query_system/src/dep_graph/graph.rs @@ -535,17 +535,22 @@ impl<K: DepKind> DepGraph<K> { // value to an existing node. // // For sanity, we still check that the loaded stable hash and the new one match. - if let Some(prev_index) = data.previous.node_to_index_opt(&node) - && let Some(dep_node_index) = { data.current.prev_index_to_index.lock()[prev_index] } - { - crate::query::incremental_verify_ich(cx, data, result, prev_index, hash_result); + if let Some(prev_index) = data.previous.node_to_index_opt(&node) { + let dep_node_index = data.current.prev_index_to_index.lock()[prev_index]; + if let Some(dep_node_index) = dep_node_index { + crate::query::incremental_verify_ich(cx, data, result, prev_index, hash_result); - #[cfg(debug_assertions)] - if hash_result.is_some() { - data.current.record_edge(dep_node_index, node, data.prev_fingerprint_of(prev_index)); - } + #[cfg(debug_assertions)] + if hash_result.is_some() { + data.current.record_edge( + dep_node_index, + node, + data.prev_fingerprint_of(prev_index), + ); + } - return dep_node_index; + return dep_node_index; + } } let mut edges = SmallVec::new(); |
