File tree 1 file changed +5
-12
lines changed 1 file changed +5
-12
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ use crate::hygiene::SyntaxContext;
8
8
use crate :: SESSION_GLOBALS ;
9
9
use crate :: { BytePos , SpanData } ;
10
10
11
- use rustc_data_structures:: fx:: FxHashMap ;
11
+ use rustc_data_structures:: fx:: FxIndexSet ;
12
12
13
13
/// A compressed span.
14
14
///
@@ -111,25 +111,18 @@ impl Span {
111
111
112
112
#[ derive( Default ) ]
113
113
pub struct SpanInterner {
114
- spans : FxHashMap < SpanData , u32 > ,
115
- span_data : Vec < SpanData > ,
114
+ spans : FxIndexSet < SpanData > ,
116
115
}
117
116
118
117
impl SpanInterner {
119
118
fn intern ( & mut self , span_data : & SpanData ) -> u32 {
120
- if let Some ( index) = self . spans . get ( span_data) {
121
- return * index;
122
- }
123
-
124
- let index = self . spans . len ( ) as u32 ;
125
- self . span_data . push ( * span_data) ;
126
- self . spans . insert ( * span_data, index) ;
127
- index
119
+ let ( index, _) = self . spans . insert_full ( * span_data) ;
120
+ index as u32
128
121
}
129
122
130
123
#[ inline]
131
124
fn get ( & self , index : u32 ) -> & SpanData {
132
- & self . span_data [ index as usize ]
125
+ & self . spans [ index as usize ]
133
126
}
134
127
}
135
128
You can’t perform that action at this time.
0 commit comments