@@ -617,51 +617,38 @@ impl Mutant {
617
617
. iter ( )
618
618
. filter_map ( |x| x. upgrade ( ) )
619
619
. next ( ) ,
620
- _ => None ,
620
+ _ => return ,
621
621
} ;
622
622
623
- let merger: [ Option < & Mutant > ; 3 ] = [
624
- descendant. as_ref ( ) . and_then ( |x| x. try_unwrap_mutant ( ) ) ,
625
- Some ( self ) ,
626
- self . ancestor . try_unwrap_mutant ( ) ,
627
- ] ;
623
+ let descendant_inner = match descendant. as_ref ( ) . and_then ( |x| x. try_unwrap_mutant ( ) ) {
624
+ Some ( x) => x,
625
+ None => return ,
626
+ } ;
628
627
629
- // if there is nothing to merge, return
630
- if merger[ 0 ] . is_none ( ) && merger[ 2 ] . is_none ( ) {
631
- return ;
632
- }
628
+ let merger: [ & Mutant ; 2 ] = [ descendant_inner, self ] ;
633
629
634
630
// aggregate changes
635
631
let changes: HashMap < usize , ( Symbol , Symbol ) > = merger
636
632
. iter ( )
637
633
. rev ( )
638
- . flatten ( )
639
634
. flat_map ( |x| x. changes . iter ( ) )
640
635
. map ( |( position, change) | ( * position, * change) )
641
636
. collect ( ) ;
642
637
643
- // last is the node furthest away from the wildtype
644
- // this node should be replaced, it is the node that may still be
645
- // visible
646
- let last = * merger. iter ( ) . flatten ( ) . next ( ) . unwrap ( ) ;
647
-
648
- // first is the node closest to the wildtype
649
- let first = * merger. iter ( ) . rev ( ) . flatten ( ) . next ( ) . unwrap ( ) ;
650
-
651
638
// determine generation
652
- let generation = last . get_generation ( ) ;
639
+ let generation = descendant_inner . get_generation ( ) ;
653
640
654
641
// extract ancestor and wildtype
655
- let ancestor = first . ancestor . clone ( ) ;
656
- let wildtype = first . wildtype . clone ( ) ;
642
+ let ancestor = self . ancestor . clone ( ) ;
643
+ let wildtype = self . wildtype . clone ( ) ;
657
644
658
645
// // we need to decrement the dirty descendants of the ancestor
659
646
// // because it will be decremented when the previous node gets removed
660
647
// ancestor.decrement_dirty_descendants();
661
648
662
649
// create new node
663
650
unsafe {
664
- Mutant :: new_and_replace ( last , ancestor, wildtype, changes, generation) ;
651
+ Mutant :: new_and_replace ( descendant_inner , ancestor, wildtype, changes, generation) ;
665
652
} ;
666
653
}
667
654
}
0 commit comments