From afe4c16b294312b7aeb920e9a988a3eaca580d3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20K=C3=A5re=20Alsaker?= Date: Sat, 25 Mar 2023 03:12:41 +0100 Subject: [PATCH] Split the `if` to release the lock earlier --- .../rustc_query_system/src/dep_graph/graph.rs | 23 +++++++++++-------- 1 file 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 DepGraph { // 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();