@@ -48,7 +48,7 @@ pub struct PerCrateAnalysis {
48
48
pub ref_spans : HashMap < Id , Vec < Span > > ,
49
49
pub globs : HashMap < Span , Glob > ,
50
50
pub impls : HashMap < Id , Vec < Span > > ,
51
- pub idents : Idents ,
51
+ pub idents : HashMap < PathBuf , IdentsByLine > ,
52
52
53
53
pub root_id : Option < Id > ,
54
54
pub timestamp : SystemTime ,
@@ -107,6 +107,12 @@ pub type Idents = HashMap<PathBuf, IdentsByLine>;
107
107
pub type IdentsByLine = BTreeMap < Row < ZeroIndexed > , IdentsByColumn > ;
108
108
pub type IdentsByColumn = BTreeMap < Column < ZeroIndexed > , IdentBound > ;
109
109
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.
110
116
#[ derive( new, Clone , Debug ) ]
111
117
pub struct IdentBound {
112
118
pub column_end : Column < ZeroIndexed > ,
@@ -167,7 +173,7 @@ impl PerCrateAnalysis {
167
173
ref_spans : HashMap :: new ( ) ,
168
174
globs : HashMap :: new ( ) ,
169
175
impls : HashMap :: new ( ) ,
170
- idents : Idents :: new ( ) ,
176
+ idents : HashMap :: new ( ) ,
171
177
root_id : None ,
172
178
timestamp,
173
179
path,
@@ -224,7 +230,7 @@ impl PerCrateAnalysis {
224
230
} )
225
231
. collect :: < Vec < Ident > > ( )
226
232
} )
227
- . unwrap_or_else ( || Vec :: new ( ) )
233
+ . unwrap_or_else ( Vec :: new)
228
234
}
229
235
}
230
236
0 commit comments