Skip to content

Commit

Permalink
better naming
Browse files Browse the repository at this point in the history
  • Loading branch information
carljm committed Aug 16, 2024
1 parent ad6863d commit c2fc10f
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,14 +139,14 @@ impl<const B: usize> Iterator for BitSetIterator<'_, B> {
*cur_block_index += 1;
*cur_block = blocks[*cur_block_index];
}
let value = cur_block.trailing_zeros();
// reset the lowest set bit
let lowest_bit_set = cur_block.trailing_zeros();
// reset the lowest set bit, without a data dependency on `lowest_bit_set`
*cur_block &= cur_block.wrapping_sub(1);
// SAFETY: `value` cannot be more than 64, `cur_block_index` cannot be more than
// `B - 1`, and we check above that `B * 64 < u32::MAX`. So both `64 *
// SAFETY: `lowest_bit_set` cannot be more than 64, `cur_block_index` cannot be
// more than `B - 1`, and we check above that `B * 64 < u32::MAX`. So both `64 *
// cur_block_index` and the final value here must fit in u32.
#[allow(clippy::cast_possible_truncation)]
Some(value + (64 * *cur_block_index) as u32)
Some(lowest_bit_set + (64 * *cur_block_index) as u32)
}
Self::Heap(set_iter) => set_iter.next().copied(),
}
Expand Down

0 comments on commit c2fc10f

Please sign in to comment.