Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit c61f1c8

Browse files
committed
rustc_mir: use IndexSet in PlaceholderIndices
1 parent 42e7a0c commit c61f1c8

File tree

1 file changed

+7
-8
lines changed
  • src/librustc_mir/borrow_check/region_infer

1 file changed

+7
-8
lines changed

src/librustc_mir/borrow_check/region_infer/values.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use rustc_data_structures::fx::FxHashMap;
1+
use rustc_data_structures::fx::FxIndexSet;
22
use rustc_index::bit_set::{HybridBitSet, SparseBitMatrix};
33
use rustc_index::vec::Idx;
44
use rustc_index::vec::IndexVec;
@@ -193,26 +193,25 @@ impl<N: Idx> LivenessValues<N> {
193193
/// NLL.
194194
#[derive(Default)]
195195
crate struct PlaceholderIndices {
196-
to_index: FxHashMap<ty::PlaceholderRegion, PlaceholderIndex>,
197-
from_index: IndexVec<PlaceholderIndex, ty::PlaceholderRegion>,
196+
indices: FxIndexSet<ty::PlaceholderRegion>,
198197
}
199198

200199
impl PlaceholderIndices {
201200
crate fn insert(&mut self, placeholder: ty::PlaceholderRegion) -> PlaceholderIndex {
202-
let PlaceholderIndices { to_index, from_index } = self;
203-
*to_index.entry(placeholder).or_insert_with(|| from_index.push(placeholder))
201+
let (index, _) = self.indices.insert_full(placeholder);
202+
index.into()
204203
}
205204

206205
crate fn lookup_index(&self, placeholder: ty::PlaceholderRegion) -> PlaceholderIndex {
207-
self.to_index[&placeholder]
206+
self.indices.get_index_of(&placeholder).unwrap().into()
208207
}
209208

210209
crate fn lookup_placeholder(&self, placeholder: PlaceholderIndex) -> ty::PlaceholderRegion {
211-
self.from_index[placeholder]
210+
self.indices[placeholder.index()]
212211
}
213212

214213
crate fn len(&self) -> usize {
215-
self.from_index.len()
214+
self.indices.len()
216215
}
217216
}
218217

0 commit comments

Comments
 (0)