@@ -1232,76 +1232,48 @@ impl<K: DepKind> CurrentDepGraph<K> {
1232
1232
self . node_intern_event_id . map ( |eid| profiler. generic_activity_with_event_id ( eid) ) ;
1233
1233
1234
1234
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
+
1235
1258
// Determine the color and index of the new `DepNode`.
1236
1259
if let Some ( fingerprint) = fingerprint {
1237
1260
if fingerprint == prev_graph. fingerprint_by_index ( prev_index) {
1238
- if print_status {
1239
- eprintln ! ( "[task::green] {key:?}" ) ;
1240
- }
1241
-
1242
1261
// This is a green node: it existed in the previous compilation,
1243
1262
// 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) ;
1258
1264
( dep_node_index, Some ( ( prev_index, DepNodeColor :: Green ( dep_node_index) ) ) )
1259
1265
} else {
1260
- if print_status {
1261
- eprintln ! ( "[task::red] {key:?}" ) ;
1262
- }
1263
-
1264
1266
// This is a red node: it existed in the previous compilation, its query
1265
1267
// 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) ;
1280
1269
( dep_node_index, Some ( ( prev_index, DepNodeColor :: Red ) ) )
1281
1270
}
1282
1271
} else {
1283
- if print_status {
1284
- eprintln ! ( "[task::unknown] {key:?}" ) ;
1285
- }
1286
-
1287
1272
// This is a red node, effectively: it existed in the previous compilation
1288
1273
// session, its query was re-executed, but it doesn't compute a result hash
1289
1274
// (i.e. it represents a `no_hash` query), so we have no way of determining
1290
1275
// 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 ) ;
1305
1277
( dep_node_index, Some ( ( prev_index, DepNodeColor :: Red ) ) )
1306
1278
}
1307
1279
} else {
0 commit comments