Remove Iter
and SparseIter
in indexed_set.rs.
Because they're just thin wrappers around `BitIter` and `slice::Iter`.
This commit is contained in:
parent
b697409f10
commit
56be2afec5
@ -138,10 +138,8 @@ impl<T: Idx> IdxSet<T> {
|
||||
bitwise(self.words_mut(), other.words(), &Intersect)
|
||||
}
|
||||
|
||||
pub fn iter(&self) -> Iter<T> {
|
||||
Iter {
|
||||
iter: self.0.iter()
|
||||
}
|
||||
pub fn iter(&self) -> BitIter<T> {
|
||||
self.0.iter()
|
||||
}
|
||||
}
|
||||
|
||||
@ -157,18 +155,6 @@ impl<T: Idx> SubtractFromIdxSet<T> for IdxSet<T> {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Iter<'a, T: Idx> {
|
||||
iter: BitIter<'a, T>
|
||||
}
|
||||
|
||||
impl<'a, T: Idx> Iterator for Iter<'a, T> {
|
||||
type Item = T;
|
||||
|
||||
fn next(&mut self) -> Option<T> {
|
||||
self.iter.next()
|
||||
}
|
||||
}
|
||||
|
||||
const SPARSE_MAX: usize = 8;
|
||||
|
||||
/// A sparse index set with a maximum of SPARSE_MAX elements. Used by
|
||||
@ -221,10 +207,8 @@ impl<T: Idx> SparseIdxSet<T> {
|
||||
dense
|
||||
}
|
||||
|
||||
fn iter(&self) -> SparseIter<T> {
|
||||
SparseIter {
|
||||
iter: self.0.iter(),
|
||||
}
|
||||
fn iter(&self) -> slice::Iter<T> {
|
||||
self.0.iter()
|
||||
}
|
||||
}
|
||||
|
||||
@ -248,18 +232,6 @@ impl<T: Idx> SubtractFromIdxSet<T> for SparseIdxSet<T> {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct SparseIter<'a, T: Idx> {
|
||||
iter: slice::Iter<'a, T>,
|
||||
}
|
||||
|
||||
impl<'a, T: Idx> Iterator for SparseIter<'a, T> {
|
||||
type Item = T;
|
||||
|
||||
fn next(&mut self) -> Option<T> {
|
||||
self.iter.next().map(|e| *e)
|
||||
}
|
||||
}
|
||||
|
||||
/// Like IdxSet, but with a hybrid representation: sparse when there are few
|
||||
/// elements in the set, but dense when there are many. It's especially
|
||||
/// efficient for sets that typically have a small number of elements, but a
|
||||
@ -370,8 +342,8 @@ impl<T: Idx> SubtractFromIdxSet<T> for HybridIdxSet<T> {
|
||||
}
|
||||
|
||||
pub enum HybridIter<'a, T: Idx> {
|
||||
Sparse(SparseIter<'a, T>),
|
||||
Dense(Iter<'a, T>),
|
||||
Sparse(slice::Iter<'a, T>),
|
||||
Dense(BitIter<'a, T>),
|
||||
}
|
||||
|
||||
impl<'a, T: Idx> Iterator for HybridIter<'a, T> {
|
||||
@ -379,7 +351,7 @@ impl<'a, T: Idx> Iterator for HybridIter<'a, T> {
|
||||
|
||||
fn next(&mut self) -> Option<T> {
|
||||
match self {
|
||||
HybridIter::Sparse(sparse) => sparse.next(),
|
||||
HybridIter::Sparse(sparse) => sparse.next().map(|e| *e),
|
||||
HybridIter::Dense(dense) => dense.next(),
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
use rustc::mir::{BasicBlock, Location};
|
||||
use rustc::ty::RegionVid;
|
||||
use rustc_data_structures::indexed_set::Iter;
|
||||
use rustc_data_structures::bitvec::BitIter;
|
||||
|
||||
use borrow_check::location::LocationIndex;
|
||||
|
||||
@ -67,7 +67,7 @@ impl<'b, 'gcx, 'tcx> Flows<'b, 'gcx, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
crate fn with_outgoing_borrows(&self, op: impl FnOnce(Iter<BorrowIndex>)) {
|
||||
crate fn with_outgoing_borrows(&self, op: impl FnOnce(BitIter<BorrowIndex>)) {
|
||||
self.borrows.with_iter_outgoing(op)
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,8 @@
|
||||
//! locations.
|
||||
|
||||
use rustc::mir::{BasicBlock, Location};
|
||||
use rustc_data_structures::indexed_set::{HybridIdxSet, IdxSet, Iter};
|
||||
use rustc_data_structures::bitvec::BitIter;
|
||||
use rustc_data_structures::indexed_set::{HybridIdxSet, IdxSet};
|
||||
|
||||
use dataflow::{BitDenotation, BlockSets, DataflowResults};
|
||||
use dataflow::move_paths::{HasMoveData, MovePathIndex};
|
||||
@ -125,7 +126,7 @@ where
|
||||
}
|
||||
|
||||
/// Returns an iterator over the elements present in the current state.
|
||||
pub fn iter_incoming(&self) -> iter::Peekable<Iter<BD::Idx>> {
|
||||
pub fn iter_incoming(&self) -> iter::Peekable<BitIter<BD::Idx>> {
|
||||
self.curr_state.iter().peekable()
|
||||
}
|
||||
|
||||
@ -134,7 +135,7 @@ where
|
||||
/// Invokes `f` with an iterator over the resulting state.
|
||||
pub fn with_iter_outgoing<F>(&self, f: F)
|
||||
where
|
||||
F: FnOnce(Iter<BD::Idx>),
|
||||
F: FnOnce(BitIter<BD::Idx>),
|
||||
{
|
||||
let mut curr_state = self.curr_state.clone();
|
||||
curr_state.union(&self.stmt_gen);
|
||||
|
Loading…
x
Reference in New Issue
Block a user