Skip to content

Commit 89d1247

Browse files
committed
Remove IdxSet::each_bit
1 parent 6701d90 commit 89d1247

File tree

3 files changed

+3
-39
lines changed

3 files changed

+3
-39
lines changed

src/librustc_data_structures/indexed_set.rs

-33
Original file line numberDiff line numberDiff line change
@@ -225,12 +225,6 @@ impl<T: Idx> IdxSet<T> {
225225
}
226226
}
227227

228-
/// Calls `f` on each index value held in this set, up to the
229-
/// bound `max_bits` on the size of universe of indexes.
230-
pub fn each_bit<F>(&self, max_bits: usize, f: F) where F: FnMut(T) {
231-
each_bit(self, max_bits, f)
232-
}
233-
234228
pub fn elems(&self, universe_size: usize) -> Elems<T> {
235229
Elems { i: 0, set: self, universe_size: universe_size }
236230
}
@@ -256,33 +250,6 @@ impl<'a, T: Idx> Iterator for Elems<'a, T> {
256250
}
257251
}
258252
}
259-
260-
fn each_bit<T: Idx, F>(words: &IdxSet<T>, max_bits: usize, mut f: F) where F: FnMut(T) {
261-
let usize_bits: usize = mem::size_of::<usize>() * 8;
262-
263-
for (word_index, &word) in words.words().iter().enumerate() {
264-
if word != 0 {
265-
let base_index = word_index * usize_bits;
266-
for offset in 0..usize_bits {
267-
let bit = 1 << offset;
268-
if (word & bit) != 0 {
269-
// NB: we round up the total number of bits
270-
// that we store in any given bit set so that
271-
// it is an even multiple of usize::BITS. This
272-
// means that there may be some stray bits at
273-
// the end that do not correspond to any
274-
// actual value; that's why we first check
275-
// that we are in range of bits_per_block.
276-
let bit_index = base_index + offset as usize;
277-
if bit_index >= max_bits {
278-
return;
279-
} else {
280-
f(Idx::new(bit_index));
281-
}
282-
}
283-
}
284-
}
285-
}
286253
}
287254

288255
pub struct Iter<'a, T: Idx> {

src/librustc_mir/dataflow/at_location.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,7 @@ where
8181
where
8282
F: FnMut(BD::Idx),
8383
{
84-
self.curr_state
85-
.each_bit(self.base_results.operator().bits_per_block(), f)
84+
self.curr_state.iter().for_each(f)
8685
}
8786

8887
/// Iterate over each `gen` bit in the current effect (invoke
@@ -92,8 +91,7 @@ where
9291
where
9392
F: FnMut(BD::Idx),
9493
{
95-
self.stmt_gen
96-
.each_bit(self.base_results.operator().bits_per_block(), f)
94+
self.stmt_gen.iter().for_each(f)
9795
}
9896

9997
pub fn new(results: DataflowResults<BD>) -> Self {

src/librustc_mir/dataflow/mod.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -444,8 +444,7 @@ pub struct DataflowState<O: BitDenotation>
444444
impl<O: BitDenotation> DataflowState<O> {
445445
pub fn each_bit<F>(&self, words: &IdxSet<O::Idx>, f: F) where F: FnMut(O::Idx)
446446
{
447-
let bits_per_block = self.operator.bits_per_block();
448-
words.each_bit(bits_per_block, f)
447+
words.iter().for_each(f)
449448
}
450449

451450
pub(crate) fn interpret_set<'c, P>(&self,

0 commit comments

Comments
 (0)