mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 06:44:35 +00:00
alloc id is indexmapped
This commit is contained in:
parent
0f27c1b5b5
commit
5f079dd2ff
@ -107,12 +107,13 @@ impl<'tcx> Tables<'tcx> {
|
||||
|
||||
fn create_alloc_id(&mut self, aid: AllocId) -> stable_mir::AllocId {
|
||||
// FIXME: this becomes inefficient when we have too many ids
|
||||
if let Some(i) = self.alloc_ids.iter().position(|a| *a == aid) {
|
||||
return stable_mir::AllocId(i);
|
||||
};
|
||||
let id = self.def_ids.len();
|
||||
self.alloc_ids.push(aid);
|
||||
stable_mir::AllocId(id)
|
||||
if let Some(i) = self.alloc_ids.get(&aid) {
|
||||
return *i;
|
||||
} else {
|
||||
let id = self.def_ids.len();
|
||||
self.alloc_ids.insert(aid, stable_mir::AllocId(id));
|
||||
stable_mir::AllocId(id)
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn create_span(&mut self, span: Span) -> stable_mir::ty::Span {
|
||||
@ -136,7 +137,7 @@ pub fn run(tcx: TyCtxt<'_>, f: impl FnOnce()) {
|
||||
Tables {
|
||||
tcx,
|
||||
def_ids: fx::FxIndexMap::default(),
|
||||
alloc_ids: vec![],
|
||||
alloc_ids: fx::FxIndexMap::default(),
|
||||
spans: vec![],
|
||||
types: vec![],
|
||||
},
|
||||
|
@ -196,7 +196,7 @@ impl<S, R: PartialEq> PartialEq<R> for MaybeStable<S, R> {
|
||||
pub struct Tables<'tcx> {
|
||||
pub tcx: TyCtxt<'tcx>,
|
||||
pub def_ids: FxIndexMap<DefId, stable_mir::DefId>,
|
||||
pub alloc_ids: Vec<AllocId>,
|
||||
pub alloc_ids: FxIndexMap<AllocId, stable_mir::AllocId>,
|
||||
pub spans: Vec<rustc_span::Span>,
|
||||
pub types: Vec<MaybeStable<stable_mir::ty::TyKind, Ty<'tcx>>>,
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user