@@ -48,7 +48,7 @@ pub struct PerCrateAnalysis {
4848 pub ref_spans : HashMap < Id , Vec < Span > > ,
4949 pub globs : HashMap < Span , Glob > ,
5050 pub impls : HashMap < Id , Vec < Span > > ,
51- pub idents : Idents ,
51+ pub idents : HashMap < PathBuf , IdentsByLine > ,
5252
5353 pub root_id : Option < Id > ,
5454 pub timestamp : SystemTime ,
@@ -107,6 +107,12 @@ pub type Idents = HashMap<PathBuf, IdentsByLine>;
107107pub type IdentsByLine = BTreeMap < Row < ZeroIndexed > , IdentsByColumn > ;
108108pub type IdentsByColumn = BTreeMap < Column < ZeroIndexed > , IdentBound > ;
109109
110+ /// We store the identifiers for a file in a BTreeMap ordered by starting index.
111+ /// This struct contains the rest of the information we need to create an `Ident`.
112+ ///
113+ /// We're optimising for space, rather than speed (of getting an Ident), because
114+ /// we have to build the whole index for every file (which is a lot for a large
115+ /// project), whereas we only get idents a few at a time and not very often.
110116#[ derive( new, Clone , Debug ) ]
111117pub struct IdentBound {
112118 pub column_end : Column < ZeroIndexed > ,
@@ -167,7 +173,7 @@ impl PerCrateAnalysis {
167173 ref_spans : HashMap :: new ( ) ,
168174 globs : HashMap :: new ( ) ,
169175 impls : HashMap :: new ( ) ,
170- idents : Idents :: new ( ) ,
176+ idents : HashMap :: new ( ) ,
171177 root_id : None ,
172178 timestamp,
173179 path,
@@ -224,7 +230,7 @@ impl PerCrateAnalysis {
224230 } )
225231 . collect :: < Vec < Ident > > ( )
226232 } )
227- . unwrap_or_else ( || Vec :: new ( ) )
233+ . unwrap_or_else ( Vec :: new)
228234 }
229235}
230236
0 commit comments