File tree Expand file tree Collapse file tree 1 file changed +5
-12
lines changed Expand file tree Collapse file tree 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;
88use crate :: SESSION_GLOBALS ;
99use crate :: { BytePos , SpanData } ;
1010
11- use rustc_data_structures:: fx:: FxHashMap ;
11+ use rustc_data_structures:: fx:: FxIndexSet ;
1212
1313/// A compressed span.
1414///
@@ -111,25 +111,18 @@ impl Span {
111111
112112#[ derive( Default ) ]
113113pub struct SpanInterner {
114- spans : FxHashMap < SpanData , u32 > ,
115- span_data : Vec < SpanData > ,
114+ spans : FxIndexSet < SpanData > ,
116115}
117116
118117impl SpanInterner {
119118 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
128121 }
129122
130123 #[ inline]
131124 fn get ( & self , index : u32 ) -> & SpanData {
132- & self . span_data [ index as usize ]
125+ & self . spans [ index as usize ]
133126 }
134127}
135128
You can’t perform that action at this time.
0 commit comments