@@ -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