about summary refs log tree commit diff
diff options
context:
space:
mode:
authorvarkor <github@varkor.com>2018-03-06 01:00:44 +0000
committervarkor <github@varkor.com>2018-03-06 01:14:36 +0000
commit89d12478ac4f56e45da7ece5d5cac983897653d6 (patch)
treea84edc1cf3c7039ecdc03f48a07c076777e9afdf
parent6701d9020f0deb0e8d673fe5ad1247514b3e9db3 (diff)
downloadrust-89d12478ac4f56e45da7ece5d5cac983897653d6.tar.gz
rust-89d12478ac4f56e45da7ece5d5cac983897653d6.zip
Remove IdxSet::each_bit
-rw-r--r--src/librustc_data_structures/indexed_set.rs33
-rw-r--r--src/librustc_mir/dataflow/at_location.rs6
-rw-r--r--src/librustc_mir/dataflow/mod.rs3
3 files changed, 3 insertions, 39 deletions
diff --git a/src/librustc_data_structures/indexed_set.rs b/src/librustc_data_structures/indexed_set.rs
index 7c926cc784b..34457d94c3a 100644
--- a/src/librustc_data_structures/indexed_set.rs
+++ b/src/librustc_data_structures/indexed_set.rs
@@ -225,12 +225,6 @@ impl<T: Idx> IdxSet<T> {
         }
     }
 
-    /// Calls `f` on each index value held in this set, up to the
-    /// bound `max_bits` on the size of universe of indexes.
-    pub fn each_bit<F>(&self, max_bits: usize, f: F) where F: FnMut(T) {
-        each_bit(self, max_bits, f)
-    }
-
     pub fn elems(&self, universe_size: usize) -> Elems<T> {
         Elems { i: 0, set: self, universe_size: universe_size }
     }
@@ -256,33 +250,6 @@ impl<'a, T: Idx> Iterator for Elems<'a, T> {
         }
     }
 }
-
-fn each_bit<T: Idx, F>(words: &IdxSet<T>, max_bits: usize, mut f: F) where F: FnMut(T) {
-    let usize_bits: usize = mem::size_of::<usize>() * 8;
-
-    for (word_index, &word) in words.words().iter().enumerate() {
-        if word != 0 {
-            let base_index = word_index * usize_bits;
-            for offset in 0..usize_bits {
-                let bit = 1 << offset;
-                if (word & bit) != 0 {
-                    // NB: we round up the total number of bits
-                    // that we store in any given bit set so that
-                    // it is an even multiple of usize::BITS. This
-                    // means that there may be some stray bits at
-                    // the end that do not correspond to any
-                    // actual value; that's why we first check
-                    // that we are in range of bits_per_block.
-                    let bit_index = base_index + offset as usize;
-                    if bit_index >= max_bits {
-                        return;
-                    } else {
-                        f(Idx::new(bit_index));
-                    }
-                }
-            }
-        }
-    }
 }
 
 pub struct Iter<'a, T: Idx> {
diff --git a/src/librustc_mir/dataflow/at_location.rs b/src/librustc_mir/dataflow/at_location.rs
index 30248ccf931..32ca513d7df 100644
--- a/src/librustc_mir/dataflow/at_location.rs
+++ b/src/librustc_mir/dataflow/at_location.rs
@@ -81,8 +81,7 @@ where
     where
         F: FnMut(BD::Idx),
     {
-        self.curr_state
-            .each_bit(self.base_results.operator().bits_per_block(), f)
+        self.curr_state.iter().for_each(f)
     }
 
     /// Iterate over each `gen` bit in the current effect (invoke
@@ -92,8 +91,7 @@ where
     where
         F: FnMut(BD::Idx),
     {
-        self.stmt_gen
-            .each_bit(self.base_results.operator().bits_per_block(), f)
+        self.stmt_gen.iter().for_each(f)
     }
 
     pub fn new(results: DataflowResults<BD>) -> Self {
diff --git a/src/librustc_mir/dataflow/mod.rs b/src/librustc_mir/dataflow/mod.rs
index aa7bb6f9778..7785b6ec173 100644
--- a/src/librustc_mir/dataflow/mod.rs
+++ b/src/librustc_mir/dataflow/mod.rs
@@ -444,8 +444,7 @@ pub struct DataflowState<O: BitDenotation>
 impl<O: BitDenotation> DataflowState<O> {
     pub fn each_bit<F>(&self, words: &IdxSet<O::Idx>, f: F) where F: FnMut(O::Idx)
     {
-        let bits_per_block = self.operator.bits_per_block();
-        words.each_bit(bits_per_block, f)
+        words.iter().for_each(f)
     }
 
     pub(crate) fn interpret_set<'c, P>(&self,