@@ -1232,76 +1232,48 @@ impl<K: DepKind> CurrentDepGraph<K> {
12321232 self . node_intern_event_id . map ( |eid| profiler. generic_activity_with_event_id ( eid) ) ;
12331233
12341234 if let Some ( prev_index) = prev_graph. node_to_index_opt ( & key) {
1235+ let get_dep_node_index = |color, fingerprint| {
1236+ if print_status {
1237+ eprintln ! ( "[task::{color:}] {key:?}" ) ;
1238+ }
1239+
1240+ let mut prev_index_to_index = self . prev_index_to_index . lock ( ) ;
1241+
1242+ let dep_node_index = match prev_index_to_index[ prev_index] {
1243+ Some ( dep_node_index) => dep_node_index,
1244+ None => {
1245+ let dep_node_index =
1246+ self . encoder . borrow ( ) . send ( profiler, key, fingerprint, edges) ;
1247+ prev_index_to_index[ prev_index] = Some ( dep_node_index) ;
1248+ dep_node_index
1249+ }
1250+ } ;
1251+
1252+ #[ cfg( debug_assertions) ]
1253+ self . record_edge ( dep_node_index, key, fingerprint) ;
1254+
1255+ dep_node_index
1256+ } ;
1257+
12351258 // Determine the color and index of the new `DepNode`.
12361259 if let Some ( fingerprint) = fingerprint {
12371260 if fingerprint == prev_graph. fingerprint_by_index ( prev_index) {
1238- if print_status {
1239- eprintln ! ( "[task::green] {key:?}" ) ;
1240- }
1241-
12421261 // This is a green node: it existed in the previous compilation,
12431262 // its query was re-executed, and it has the same result as before.
1244- let mut prev_index_to_index = self . prev_index_to_index . lock ( ) ;
1245-
1246- let dep_node_index = match prev_index_to_index[ prev_index] {
1247- Some ( dep_node_index) => dep_node_index,
1248- None => {
1249- let dep_node_index =
1250- self . encoder . borrow ( ) . send ( profiler, key, fingerprint, edges) ;
1251- prev_index_to_index[ prev_index] = Some ( dep_node_index) ;
1252- dep_node_index
1253- }
1254- } ;
1255-
1256- #[ cfg( debug_assertions) ]
1257- self . record_edge ( dep_node_index, key, fingerprint) ;
1263+ let dep_node_index = get_dep_node_index ( "green" , fingerprint) ;
12581264 ( dep_node_index, Some ( ( prev_index, DepNodeColor :: Green ( dep_node_index) ) ) )
12591265 } else {
1260- if print_status {
1261- eprintln ! ( "[task::red] {key:?}" ) ;
1262- }
1263-
12641266 // This is a red node: it existed in the previous compilation, its query
12651267 // was re-executed, but it has a different result from before.
1266- let mut prev_index_to_index = self . prev_index_to_index . lock ( ) ;
1267-
1268- let dep_node_index = match prev_index_to_index[ prev_index] {
1269- Some ( dep_node_index) => dep_node_index,
1270- None => {
1271- let dep_node_index =
1272- self . encoder . borrow ( ) . send ( profiler, key, fingerprint, edges) ;
1273- prev_index_to_index[ prev_index] = Some ( dep_node_index) ;
1274- dep_node_index
1275- }
1276- } ;
1277-
1278- #[ cfg( debug_assertions) ]
1279- self . record_edge ( dep_node_index, key, fingerprint) ;
1268+ let dep_node_index = get_dep_node_index ( "red" , fingerprint) ;
12801269 ( dep_node_index, Some ( ( prev_index, DepNodeColor :: Red ) ) )
12811270 }
12821271 } else {
1283- if print_status {
1284- eprintln ! ( "[task::unknown] {key:?}" ) ;
1285- }
1286-
12871272 // This is a red node, effectively: it existed in the previous compilation
12881273 // session, its query was re-executed, but it doesn't compute a result hash
12891274 // (i.e. it represents a `no_hash` query), so we have no way of determining
12901275 // whether or not the result was the same as before.
1291- let mut prev_index_to_index = self . prev_index_to_index . lock ( ) ;
1292-
1293- let dep_node_index = match prev_index_to_index[ prev_index] {
1294- Some ( dep_node_index) => dep_node_index,
1295- None => {
1296- let dep_node_index =
1297- self . encoder . borrow ( ) . send ( profiler, key, Fingerprint :: ZERO , edges) ;
1298- prev_index_to_index[ prev_index] = Some ( dep_node_index) ;
1299- dep_node_index
1300- }
1301- } ;
1302-
1303- #[ cfg( debug_assertions) ]
1304- self . record_edge ( dep_node_index, key, Fingerprint :: ZERO ) ;
1276+ let dep_node_index = get_dep_node_index ( "unknown" , Fingerprint :: ZERO ) ;
13051277 ( dep_node_index, Some ( ( prev_index, DepNodeColor :: Red ) ) )
13061278 }
13071279 } else {
0 commit comments