@@ -149,29 +149,33 @@ impl RootDatabase {
149
149
}
150
150
151
151
pub fn update_parse_query_lru_capacity ( & mut self , lru_capacity : Option < usize > ) {
152
- let lru_capacity = lru_capacity. unwrap_or ( base_db:: DEFAULT_LRU_CAP ) ;
152
+ let lru_capacity = lru_capacity. unwrap_or ( base_db:: DEFAULT_PARSE_LRU_CAP ) ;
153
153
base_db:: ParseQuery . in_db_mut ( self ) . set_lru_capacity ( lru_capacity) ;
154
- hir:: db:: ParseMacroExpansionQuery . in_db_mut ( self ) . set_lru_capacity ( lru_capacity) ;
155
- hir:: db:: MacroExpandQuery . in_db_mut ( self ) . set_lru_capacity ( lru_capacity) ;
154
+ // macro expansions are usually rather small, so we can afford to keep more of them alive
155
+ hir:: db:: ParseMacroExpansionQuery . in_db_mut ( self ) . set_lru_capacity ( 4 * lru_capacity) ;
156
+ hir:: db:: MacroExpandQuery . in_db_mut ( self ) . set_lru_capacity ( 4 * lru_capacity) ;
156
157
}
157
158
158
159
pub fn update_lru_capacities ( & mut self , lru_capacities : & FxHashMap < Box < str > , usize > ) {
159
160
use hir:: db as hir_db;
160
161
161
162
base_db:: ParseQuery . in_db_mut ( self ) . set_lru_capacity (
162
- lru_capacities. get ( stringify ! ( ParseQuery ) ) . copied ( ) . unwrap_or ( base_db:: DEFAULT_LRU_CAP ) ,
163
+ lru_capacities
164
+ . get ( stringify ! ( ParseQuery ) )
165
+ . copied ( )
166
+ . unwrap_or ( base_db:: DEFAULT_PARSE_LRU_CAP ) ,
163
167
) ;
164
168
hir_db:: ParseMacroExpansionQuery . in_db_mut ( self ) . set_lru_capacity (
165
169
lru_capacities
166
170
. get ( stringify ! ( ParseMacroExpansionQuery ) )
167
171
. copied ( )
168
- . unwrap_or ( base_db:: DEFAULT_LRU_CAP ) ,
172
+ . unwrap_or ( 4 * base_db:: DEFAULT_PARSE_LRU_CAP ) ,
169
173
) ;
170
174
hir_db:: MacroExpandQuery . in_db_mut ( self ) . set_lru_capacity (
171
175
lru_capacities
172
176
. get ( stringify ! ( MacroExpandQuery ) )
173
177
. copied ( )
174
- . unwrap_or ( base_db:: DEFAULT_LRU_CAP ) ,
178
+ . unwrap_or ( 4 * base_db:: DEFAULT_PARSE_LRU_CAP ) ,
175
179
) ;
176
180
177
181
macro_rules! update_lru_capacity_per_query {
0 commit comments