Skip to content

Commit 522bff3

Browse files
committed
migrate to new methods
1 parent a51f1ee commit 522bff3

File tree

3 files changed

+31
-69
lines changed

3 files changed

+31
-69
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -323,18 +323,18 @@ impl AggregatedDataUpdate {
323323
);
324324

325325
if !aggregated_update.is_zero() {
326-
let dirty_state = task.dirty_state();
326+
let dirtyness_and_session = task.dirtyness_and_session();
327327
let task_id = task.id();
328328
update!(task, AggregatedDirtyContainerCount, |old: Option<
329329
DirtyContainerCount,
330330
>| {
331331
let mut new = old.unwrap_or_default();
332-
if let Some(dirty_state) = dirty_state {
333-
new.update_with_dirty_state(&dirty_state);
332+
if let Some((dirtyness, clean_in_session)) = dirtyness_and_session {
333+
new.update_with_dirtyness_and_session(dirtyness, clean_in_session);
334334
}
335335
let aggregated_update = new.update_count(&aggregated_update);
336-
if let Some(dirty_state) = dirty_state {
337-
new.undo_update_with_dirty_state(&dirty_state);
336+
if let Some((dirtyness, clean_in_session)) = dirtyness_and_session {
337+
new.undo_update_with_dirtyness_and_session(dirtyness, clean_in_session);
338338
}
339339
if !aggregated_update.is_zero() {
340340
result.dirty_container_update = Some((task_id, aggregated_update));

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ use crate::{
1414
storage::{get, get_mut, remove},
1515
},
1616
data::{
17-
CachedDataItem, CachedDataItemKey, CachedDataItemValue, DirtyState, Dirtyness,
18-
InProgressState, InProgressStateInner,
17+
CachedDataItem, CachedDataItemKey, CachedDataItemValue, Dirtyness, InProgressState,
18+
InProgressStateInner,
1919
},
2020
};
2121

@@ -294,9 +294,8 @@ pub fn make_task_dirty_internal(
294294
.entered();
295295

296296
let should_schedule = {
297-
let aggregated_update = dirty_container.update_with_dirty_state(&DirtyState {
298-
clean_in_session: None,
299-
});
297+
let aggregated_update =
298+
dirty_container.update_with_dirtyness_and_session(Dirtyness::Dirty, None);
300299
if !aggregated_update.is_zero() {
301300
queue.extend(AggregationUpdateJob::data_update(
302301
&mut task,

turbopack/crates/turbo-tasks-backend/src/data.rs

Lines changed: 22 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -257,15 +257,6 @@ impl DirtyContainerCount {
257257
diff
258258
}
259259

260-
/// Applies a dirty state to the count. Returns an aggregated count that represents the change.
261-
pub fn update_with_dirty_state(&mut self, dirty: &DirtyState) -> DirtyContainerCount {
262-
if let Some(clean_in_session) = dirty.clean_in_session {
263-
self.update_session_dependent(clean_in_session, 1)
264-
} else {
265-
self.update(1)
266-
}
267-
}
268-
269260
/// Applies a dirtyness to the count. Returns an aggregated count that represents the change.
270261
pub fn update_with_dirtyness_and_session(
271262
&mut self,
@@ -279,16 +270,6 @@ impl DirtyContainerCount {
279270
}
280271
}
281272

282-
/// Undoes the effect of a dirty state on the count. Returns an aggregated count that represents
283-
/// the change.
284-
pub fn undo_update_with_dirty_state(&mut self, dirty: &DirtyState) -> DirtyContainerCount {
285-
if let Some(clean_in_session) = dirty.clean_in_session {
286-
self.update_session_dependent(clean_in_session, -1)
287-
} else {
288-
self.update(-1)
289-
}
290-
}
291-
292273
/// Undoes the effect of a dirtyness on the count. Returns an aggregated count that represents
293274
/// the change.
294275
pub fn undo_update_with_dirtyness_and_session(
@@ -303,18 +284,6 @@ impl DirtyContainerCount {
303284
}
304285
}
305286

306-
/// Replaces the old dirty state with the new one. Returns an aggregated count that represents
307-
/// the change.
308-
pub fn replace_dirty_state(
309-
&mut self,
310-
old: &DirtyState,
311-
new: &DirtyState,
312-
) -> DirtyContainerCount {
313-
let mut diff = self.undo_update_with_dirty_state(old);
314-
diff.update_count(&self.update_with_dirty_state(new));
315-
diff
316-
}
317-
318287
/// Replaces the old dirtyness with the new one. Returns an aggregated count that represents
319288
/// the change.
320289
pub fn replace_dirtyness_and_session(
@@ -462,37 +431,33 @@ mod dirty_container_count_tests {
462431
}
463432

464433
#[test]
465-
fn test_update_with_dirty_state() {
434+
fn test_update_with_dirtyness_and_session() {
466435
let mut count = DirtyContainerCount::default();
467-
let dirty = DirtyState {
468-
clean_in_session: None,
469-
};
470-
let diff = count.update_with_dirty_state(&dirty);
436+
let diff = count.update_with_dirtyness_and_session(Dirtyness::Dirty, None);
471437
assert!(!count.is_zero());
472438
assert_eq!(count.get(SESSION_1), 1);
473439
assert_eq!(diff.get(SESSION_1), 1);
474440
assert_eq!(count.get(SESSION_2), 1);
475441
assert_eq!(diff.get(SESSION_2), 1);
476442

477-
let diff = count.undo_update_with_dirty_state(&dirty);
443+
let diff = count.undo_update_with_dirtyness_and_session(Dirtyness::Dirty, None);
478444
assert!(count.is_zero());
479445
assert_eq!(count.get(SESSION_1), 0);
480446
assert_eq!(diff.get(SESSION_1), -1);
481447
assert_eq!(count.get(SESSION_2), 0);
482448
assert_eq!(diff.get(SESSION_2), -1);
483449

484450
let mut count = DirtyContainerCount::default();
485-
let dirty = DirtyState {
486-
clean_in_session: Some(SESSION_1),
487-
};
488-
let diff = count.update_with_dirty_state(&dirty);
451+
let diff =
452+
count.update_with_dirtyness_and_session(Dirtyness::SessionDependent, Some(SESSION_1));
489453
assert!(!count.is_zero());
490454
assert_eq!(count.get(SESSION_1), 0);
491455
assert_eq!(diff.get(SESSION_1), 0);
492456
assert_eq!(count.get(SESSION_2), 1);
493457
assert_eq!(diff.get(SESSION_2), 1);
494458

495-
let diff = count.undo_update_with_dirty_state(&dirty);
459+
let diff = count
460+
.undo_update_with_dirtyness_and_session(Dirtyness::SessionDependent, Some(SESSION_1));
496461
assert!(count.is_zero());
497462
assert_eq!(count.get(SESSION_1), 0);
498463
assert_eq!(diff.get(SESSION_1), 0);
@@ -501,31 +466,29 @@ mod dirty_container_count_tests {
501466
}
502467

503468
#[test]
504-
fn test_replace_dirty_state() {
469+
fn test_replace_dirtyness_and_session() {
505470
let mut count = DirtyContainerCount::default();
506-
let old = DirtyState {
507-
clean_in_session: None,
508-
};
509-
let new = DirtyState {
510-
clean_in_session: Some(SESSION_1),
511-
};
512-
count.update_with_dirty_state(&old);
513-
let diff = count.replace_dirty_state(&old, &new);
471+
count.update_with_dirtyness_and_session(Dirtyness::Dirty, None);
472+
let diff = count.replace_dirtyness_and_session(
473+
Dirtyness::Dirty,
474+
None,
475+
Dirtyness::SessionDependent,
476+
Some(SESSION_1),
477+
);
514478
assert!(!count.is_zero());
515479
assert_eq!(count.get(SESSION_1), 0);
516480
assert_eq!(diff.get(SESSION_1), -1);
517481
assert_eq!(count.get(SESSION_2), 1);
518482
assert_eq!(diff.get(SESSION_2), 0);
519483

520484
let mut count = DirtyContainerCount::default();
521-
let old = DirtyState {
522-
clean_in_session: Some(SESSION_1),
523-
};
524-
let new = DirtyState {
525-
clean_in_session: None,
526-
};
527-
count.update_with_dirty_state(&old);
528-
let diff = count.replace_dirty_state(&old, &new);
485+
count.update_with_dirtyness_and_session(Dirtyness::SessionDependent, Some(SESSION_1));
486+
let diff = count.replace_dirtyness_and_session(
487+
Dirtyness::SessionDependent,
488+
Some(SESSION_1),
489+
Dirtyness::Dirty,
490+
None,
491+
);
529492
assert!(!count.is_zero());
530493
assert_eq!(count.get(SESSION_1), 1);
531494
assert_eq!(diff.get(SESSION_1), 1);

0 commit comments

Comments
 (0)