@@ -1699,14 +1699,15 @@ impl<R: Idx, C: Idx> BitMatrix<R, C> {
16991699 let ( read_start, read_end) = self . range ( read) ;
17001700 let ( write_start, write_end) = self . range ( write) ;
17011701 let words = & mut self . words [ ..] ;
1702- let mut changed = false ;
1702+ let mut changed = 0 ;
17031703 for ( read_index, write_index) in iter:: zip ( read_start..read_end, write_start..write_end) {
17041704 let word = words[ write_index] ;
17051705 let new_word = word | words[ read_index] ;
17061706 words[ write_index] = new_word;
1707- changed |= word != new_word;
1707+ // See `bitwise` for the rationale.
1708+ changed |= word ^ new_word;
17081709 }
1709- changed
1710+ changed != 0
17101711 }
17111712
17121713 /// Adds the bits from `with` to the bits from row `write`, and
@@ -1715,14 +1716,7 @@ impl<R: Idx, C: Idx> BitMatrix<R, C> {
17151716 assert ! ( write. index( ) < self . num_rows) ;
17161717 assert_eq ! ( with. domain_size( ) , self . num_columns) ;
17171718 let ( write_start, write_end) = self . range ( write) ;
1718- let mut changed = false ;
1719- for ( read_index, write_index) in iter:: zip ( 0 ..with. words . len ( ) , write_start..write_end) {
1720- let word = self . words [ write_index] ;
1721- let new_word = word | with. words [ read_index] ;
1722- self . words [ write_index] = new_word;
1723- changed |= word != new_word;
1724- }
1725- changed
1719+ bitwise ( & mut self . words [ write_start..write_end] , & with. words , |a, b| a | b)
17261720 }
17271721
17281722 /// Sets every cell in `row` to true.
0 commit comments