@@ -383,8 +383,7 @@ enum Chunk {
383
383
/// turns out to be both simpler and have better performance than
384
384
/// allocating the minimum number of words, largely because we avoid having
385
385
/// to store the length, which would make this type larger. These excess
386
- /// words are always be zero, as are any excess bits in the final in-use
387
- /// word.
386
+ /// words are always zero, as are any excess bits in the final in-use word.
388
387
///
389
388
/// The first `ChunkSize` field is always non-zero.
390
389
///
@@ -465,7 +464,7 @@ impl<T: Idx> ChunkedBitSet<T> {
465
464
}
466
465
467
466
pub fn is_empty ( & self ) -> bool {
468
- self . chunks . iter ( ) . all ( |chunk| matches ! ( chunk, Chunk :: Zeros ( ..) ) )
467
+ self . chunks . iter ( ) . all ( |chunk| matches ! ( chunk, Zeros ( ..) ) )
469
468
}
470
469
471
470
/// Returns `true` if `self` contains `elem`.
@@ -855,16 +854,16 @@ impl<T: Idx> BitRelations<ChunkedBitSet<T>> for BitSet<T> {
855
854
words = & mut words[ ..CHUNK_WORDS ] ;
856
855
}
857
856
match chunk {
858
- Chunk :: Zeros ( ..) => {
857
+ Zeros ( ..) => {
859
858
for word in words {
860
859
if * word != 0 {
861
860
changed = true ;
862
861
* word = 0 ;
863
862
}
864
863
}
865
864
}
866
- Chunk :: Ones ( ..) => ( ) ,
867
- Chunk :: Mixed ( _, _, data) => {
865
+ Ones ( ..) => ( ) ,
866
+ Mixed ( _, _, data) => {
868
867
for ( i, word) in words. iter_mut ( ) . enumerate ( ) {
869
868
let new_val = * word & data[ i] ;
870
869
if new_val != * word {
@@ -902,22 +901,22 @@ impl<T> Clone for ChunkedBitSet<T> {
902
901
903
902
pub struct ChunkedBitIter < ' a , T : Idx > {
904
903
index : usize ,
905
- bitset : & ' a ChunkedBitSet < T > ,
904
+ bit_set : & ' a ChunkedBitSet < T > ,
906
905
}
907
906
908
907
impl < ' a , T : Idx > ChunkedBitIter < ' a , T > {
909
908
#[ inline]
910
- fn new ( bitset : & ' a ChunkedBitSet < T > ) -> ChunkedBitIter < ' a , T > {
911
- ChunkedBitIter { index : 0 , bitset }
909
+ fn new ( bit_set : & ' a ChunkedBitSet < T > ) -> ChunkedBitIter < ' a , T > {
910
+ ChunkedBitIter { index : 0 , bit_set }
912
911
}
913
912
}
914
913
915
914
impl < ' a , T : Idx > Iterator for ChunkedBitIter < ' a , T > {
916
915
type Item = T ;
917
916
fn next ( & mut self ) -> Option < T > {
918
- while self . index < self . bitset . domain_size ( ) {
917
+ while self . index < self . bit_set . domain_size ( ) {
919
918
let elem = T :: new ( self . index ) ;
920
- let chunk = & self . bitset . chunks [ chunk_index ( elem) ] ;
919
+ let chunk = & self . bit_set . chunks [ chunk_index ( elem) ] ;
921
920
match & chunk {
922
921
Zeros ( chunk_domain_size) => {
923
922
self . index += * chunk_domain_size as usize ;
@@ -954,17 +953,17 @@ impl<'a, T: Idx> Iterator for ChunkedBitIter<'a, T> {
954
953
init = f ( init, item) ;
955
954
}
956
955
let start_chunk = self . index / CHUNK_BITS ;
957
- let chunks = & self . bitset . chunks [ start_chunk..] ;
956
+ let chunks = & self . bit_set . chunks [ start_chunk..] ;
958
957
for ( i, chunk) in chunks. iter ( ) . enumerate ( ) {
959
958
let base = ( start_chunk + i) * CHUNK_BITS ;
960
959
match chunk {
961
- Chunk :: Zeros ( _) => ( ) ,
962
- Chunk :: Ones ( limit) => {
960
+ Zeros ( _) => ( ) ,
961
+ Ones ( limit) => {
963
962
for j in 0 ..( * limit as usize ) {
964
963
init = f ( init, T :: new ( base + j) ) ;
965
964
}
966
965
}
967
- Chunk :: Mixed ( _, _, words) => {
966
+ Mixed ( _, _, words) => {
968
967
init = BitIter :: new ( & * * words) . fold ( init, |val, mut item : T | {
969
968
item. increment_by ( base) ;
970
969
f ( val, item)
@@ -1302,15 +1301,13 @@ impl<'a, T: Idx> Iterator for BitIter<'a, T> {
1302
1301
// Get the position of the next set bit in the current word,
1303
1302
// then clear the bit.
1304
1303
let bit_pos = self . word . trailing_zeros ( ) as usize ;
1305
- let bit = 1 << bit_pos;
1306
- self . word ^= bit;
1304
+ self . word ^= 1 << bit_pos;
1307
1305
return Some ( T :: new ( bit_pos + self . offset ) ) ;
1308
1306
}
1309
1307
1310
1308
// Move onto the next word. `wrapping_add()` is needed to handle
1311
1309
// the degenerate initial value given to `offset` in `new()`.
1312
- let word = self . iter . next ( ) ?;
1313
- self . word = * word;
1310
+ self . word = * self . iter . next ( ) ?;
1314
1311
self . offset = self . offset . wrapping_add ( WORD_BITS ) ;
1315
1312
}
1316
1313
}
0 commit comments