Changeset - b433d016e796
[Not reviewed]
0 1 0
Christopher Esterhuyse - 5 years ago 2020-02-12 18:10:32
christopheresterhuyse@gmail.com
playing around with new predicate=>state,payload storages. toward faster querying but also toward deviation detection by way of intelligible error handling
1 file changed with 4 insertions and 3 deletions:
0 comments (0 inline, 0 general)
src/runtime/polyp.rs
Show inline comments
 
@@ -245,30 +245,31 @@ impl Iterator for BitSetAndIter<'_> {
 
            fn shifty(chunk: &mut u32, shift_by: usize, next_bit_index: &mut usize) {
 
                if *chunk & ((1 << shift_by) - 1) == 0 {
 
                    *next_bit_index += shift_by;
 
                    *chunk >>= shift_by;
 
                }
 
            }
 
            shifty(&mut chunk, 16, &mut self.next_bit_index);
 
            shifty(&mut chunk, 08, &mut self.next_bit_index);
 
            shifty(&mut chunk, 04, &mut self.next_bit_index);
 
            shifty(&mut chunk, 02, &mut self.next_bit_index);
 
            shifty(&mut chunk, 01, &mut self.next_bit_index);
 
            // assert(chunk & 1 == 1)
 
            let index = self.next_u32_index * 32 + self.next_bit_index;
 

	
 
            self.next_bit_index += 1;
 
            self.cached = Some(chunk >> 1);
 
            if chunk > 0 {
 
                // assert(self.next_bit_index <= 32)
 
                // because index was calculated with self.next_bit_index - 1
 
                let index = self.next_u32_index * 32 + (self.next_bit_index - 1);
 
                // assert((self.next_bit_index-1) < 32)
 
                // because if chunk was shifted 32+ places, its contents would be zero.
 
                return Some(index);
 
            }
 
        }
 
    }
 
}
 

	
 
#[test]
 
fn test_bit_iter() {
 
    static SETS: &[&[u32]] = &[
 
        //
 
        &[0b100011000000100101101],
 
        &[0b100001000000000110100],
0 comments (0 inline, 0 general)