Skip to content

Commit 398e2b6

Browse files
committed
use shared compute logic
1 parent 82acf13 commit 398e2b6

File tree

1 file changed

+14
-41
lines changed

1 file changed

+14
-41
lines changed

turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

Lines changed: 14 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -519,12 +519,6 @@ impl AggregatedDataUpdate {
519519
old_dirty_container_count = new_dirty_container_count;
520520
};
521521

522-
let was_dirty_without_clean = is_self_dirty || old_dirty_container_count > 0;
523-
let is_dirty_without_clean = is_self_dirty || new_dirty_container_count > 0;
524-
525-
let upper_count_update =
526-
before_after_to_diff_value(was_dirty_without_clean, is_dirty_without_clean);
527-
528522
// Update AggregatedSessionDependentCleanContainerCount and compute aggregate value
529523
let new_current_session_clean_container_count;
530524
let old_current_session_clean_container_count;
@@ -551,20 +545,6 @@ impl AggregatedDataUpdate {
551545
new_current_session_clean_container_count;
552546
};
553547

554-
let was_dirty = is_self_dirty && !current_session_self_clean
555-
|| old_dirty_container_count > 0
556-
&& old_dirty_container_count - old_current_session_clean_container_count
557-
> 0;
558-
let is_dirty = is_self_dirty && !current_session_self_clean
559-
|| new_dirty_container_count > 0
560-
&& new_dirty_container_count - new_current_session_clean_container_count
561-
> 0;
562-
563-
let was_flagged_clean = was_dirty_without_clean && !was_dirty;
564-
let is_flagged_clean = is_dirty_without_clean && !is_dirty;
565-
let upper_current_session_clean_update =
566-
before_after_to_diff_value(was_flagged_clean, is_flagged_clean);
567-
568548
let compute_result = ComputeDirtyAndCleanUpdate {
569549
old_dirty_container_count,
570550
new_dirty_container_count,
@@ -576,28 +556,21 @@ impl AggregatedDataUpdate {
576556
new_current_session_self_clean: current_session_self_clean,
577557
}
578558
.compute();
579-
assert_eq!(compute_result.dirty_count_update, upper_count_update);
580-
assert_eq!(
581-
compute_result.current_session_clean_update,
582-
upper_current_session_clean_update
583-
);
584559

585-
if upper_count_update != 0 || upper_current_session_clean_update != 0 {
586-
result.dirty_container_update = Some((
587-
task_id,
588-
upper_count_update,
589-
SessionDependent::new(upper_current_session_clean_update),
590-
));
591-
}
592-
593-
if was_dirty && !is_dirty {
594-
// When the current task is no longer dirty, we need to fire the
595-
// aggregate root events and do some cleanup
596-
if let Some(activeness_state) = get_mut!(task, Activeness) {
597-
activeness_state.all_clean_event.notify(usize::MAX);
598-
activeness_state.unset_active_until_clean();
599-
if activeness_state.is_empty() {
600-
task.remove(&CachedDataItemKey::Activeness {});
560+
if let Some(aggregated_update) = compute_result.aggregated_update(task_id) {
561+
result = aggregated_update;
562+
563+
if let Some((_, count, current_session_clean)) = result.dirty_container_update
564+
&& count - *current_session_clean < 0
565+
{
566+
// When the current task is no longer dirty, we need to fire the
567+
// aggregate root events and do some cleanup
568+
if let Some(activeness_state) = get_mut!(task, Activeness) {
569+
activeness_state.all_clean_event.notify(usize::MAX);
570+
activeness_state.unset_active_until_clean();
571+
if activeness_state.is_empty() {
572+
task.remove(&CachedDataItemKey::Activeness {});
573+
}
601574
}
602575
}
603576
}

0 commit comments

Comments
 (0)