@@ -595,16 +595,17 @@ where
595595 // Remove null edges from color_fn
596596 let colors = colors. into_iter ( ) . flatten ( ) . collect :: < Vec < usize > > ( ) ;
597597
598- if colors. len ( ) <= 2 && is_match {
599- if colors . len ( ) == 1 {
598+ match ( colors. len ( ) , is_match) {
599+ ( 1 , true ) => {
600600 let c0 = colors[ 0 ] ;
601601 ensure_vector_has_index ! ( pending_list, block_id, c0) ;
602602 if let Some ( c0_block_id) = block_id[ c0] {
603603 block_list[ c0_block_id] . push ( node) ;
604604 } else {
605605 pending_list[ c0] . push ( node) ;
606606 }
607- } else if colors. len ( ) == 2 {
607+ }
608+ ( 2 , true ) => {
608609 let c0 = colors[ 0 ] ;
609610 let c1 = colors[ 1 ] ;
610611 ensure_vector_has_index ! ( pending_list, block_id, c0) ;
@@ -619,7 +620,7 @@ where
619620 let mut new_block: Vec < G :: NodeId > =
620621 Vec :: with_capacity ( pending_list[ c0] . len ( ) + pending_list[ c1] . len ( ) + 1 ) ;
621622
622- // Clears pending lits and add to new block
623+ // Clears pending list and add to new block
623624 new_block. append ( & mut pending_list[ c0] ) ;
624625 new_block. append ( & mut pending_list[ c1] ) ;
625626
@@ -631,14 +632,15 @@ where
631632 block_list. push ( new_block) ;
632633 }
633634 }
634- } else {
635- for color in colors {
636- ensure_vector_has_index ! ( pending_list, block_id, color) ;
637- if let Some ( color_block_id) = block_id[ color] {
638- block_list[ color_block_id] . append ( & mut pending_list[ color] ) ;
635+ _ => {
636+ for color in colors {
637+ ensure_vector_has_index ! ( pending_list, block_id, color) ;
638+ if let Some ( color_block_id) = block_id[ color] {
639+ block_list[ color_block_id] . append ( & mut pending_list[ color] ) ;
640+ }
641+ block_id[ color] = None ;
642+ pending_list[ color] . clear ( ) ;
639643 }
640- block_id[ color] = None ;
641- pending_list[ color] . clear ( ) ;
642644 }
643645 }
644646 }
0 commit comments