diff options
| author | Josh Stone <jistone@redhat.com> | 2020-08-07 20:48:00 -0700 |
|---|---|---|
| committer | Josh Stone <jistone@redhat.com> | 2020-08-09 12:25:22 -0700 |
| commit | c61f1c8bfa49cdaeb0ee8a8360e0d70a0fbd0b7b (patch) | |
| tree | c18ed424dab12b3721616f3405f01b3c19e8e47d | |
| parent | 42e7a0cb3a484670e27e28915a8c45809a35ccc4 (diff) | |
| download | rust-c61f1c8bfa49cdaeb0ee8a8360e0d70a0fbd0b7b.tar.gz rust-c61f1c8bfa49cdaeb0ee8a8360e0d70a0fbd0b7b.zip | |
rustc_mir: use IndexSet in PlaceholderIndices
| -rw-r--r-- | src/librustc_mir/borrow_check/region_infer/values.rs | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/librustc_mir/borrow_check/region_infer/values.rs b/src/librustc_mir/borrow_check/region_infer/values.rs index 6cd814962c6..8a5a600cfdd 100644 --- a/src/librustc_mir/borrow_check/region_infer/values.rs +++ b/src/librustc_mir/borrow_check/region_infer/values.rs @@ -1,4 +1,4 @@ -use rustc_data_structures::fx::FxHashMap; +use rustc_data_structures::fx::FxIndexSet; use rustc_index::bit_set::{HybridBitSet, SparseBitMatrix}; use rustc_index::vec::Idx; use rustc_index::vec::IndexVec; @@ -193,26 +193,25 @@ impl<N: Idx> LivenessValues<N> { /// NLL. #[derive(Default)] crate struct PlaceholderIndices { - to_index: FxHashMap<ty::PlaceholderRegion, PlaceholderIndex>, - from_index: IndexVec<PlaceholderIndex, ty::PlaceholderRegion>, + indices: FxIndexSet<ty::PlaceholderRegion>, } impl PlaceholderIndices { crate fn insert(&mut self, placeholder: ty::PlaceholderRegion) -> PlaceholderIndex { - let PlaceholderIndices { to_index, from_index } = self; - *to_index.entry(placeholder).or_insert_with(|| from_index.push(placeholder)) + let (index, _) = self.indices.insert_full(placeholder); + index.into() } crate fn lookup_index(&self, placeholder: ty::PlaceholderRegion) -> PlaceholderIndex { - self.to_index[&placeholder] + self.indices.get_index_of(&placeholder).unwrap().into() } crate fn lookup_placeholder(&self, placeholder: PlaceholderIndex) -> ty::PlaceholderRegion { - self.from_index[placeholder] + self.indices[placeholder.index()] } crate fn len(&self) -> usize { - self.from_index.len() + self.indices.len() } } |
