@@ -1226,12 +1226,16 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
1226
1226
let mut removed_data = Vec :: new ( ) ;
1227
1227
let mut old_edges = Vec :: new ( ) ;
1228
1228
1229
+ let has_children = !new_children. is_empty ( ) ;
1230
+
1229
1231
// Prepare all new children
1230
- prepare_new_children ( task_id, & mut task, & new_children, & mut queue) ;
1232
+ if has_children {
1233
+ prepare_new_children ( task_id, & mut task, & new_children, & mut queue) ;
1234
+ }
1231
1235
1232
1236
// Filter actual new children
1233
1237
for old_child in iter_many ! ( task, Child { task } => task) {
1234
- if !new_children. remove ( & old_child) {
1238
+ if !has_children || ! new_children. remove ( & old_child) {
1235
1239
old_edges. push ( OutdatedEdge :: Child ( old_child) ) ;
1236
1240
}
1237
1241
}
@@ -1296,7 +1300,7 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
1296
1300
1297
1301
drop ( task) ;
1298
1302
1299
- {
1303
+ if !queue . is_empty ( ) || !old_edges . is_empty ( ) {
1300
1304
let _span = tracing:: trace_span!( "remove old edges and prepare new children" ) . entered ( ) ;
1301
1305
// Remove outdated edges first, before removing in_progress+dirty flag.
1302
1306
// We need to make sure all outdated edges are removed before the task can potentially
@@ -1344,19 +1348,21 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
1344
1348
1345
1349
let mut queue = AggregationUpdateQueue :: new ( ) ;
1346
1350
1347
- let has_active_count =
1348
- get ! ( task, Activeness ) . map_or ( false , |activeness| activeness. active_counter > 0 ) ;
1349
- connect_children (
1350
- task_id,
1351
- & mut task,
1352
- new_children,
1353
- & mut queue,
1354
- has_active_count,
1355
- ) ;
1351
+ if has_children {
1352
+ let has_active_count =
1353
+ get ! ( task, Activeness ) . map_or ( false , |activeness| activeness. active_counter > 0 ) ;
1354
+ connect_children (
1355
+ task_id,
1356
+ & mut task,
1357
+ new_children,
1358
+ & mut queue,
1359
+ has_active_count,
1360
+ ) ;
1361
+ }
1356
1362
1357
1363
drop ( task) ;
1358
1364
1359
- {
1365
+ if has_children {
1360
1366
let _span = tracing:: trace_span!( "connect new children" ) . entered ( ) ;
1361
1367
queue. execute ( & mut ctx) ;
1362
1368
}
0 commit comments