File tree Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -114,6 +114,7 @@ pub struct InvGenerator {
114
114
/// count cache misses for `processed_tenures`
115
115
cache_misses : u128 ,
116
116
/// Disable caching (test only)
117
+ #[ cfg( test) ]
117
118
no_cache : bool ,
118
119
}
119
120
@@ -124,6 +125,7 @@ impl InvGenerator {
124
125
sortitions : HashMap :: new ( ) ,
125
126
tip_ancestor_search_depth : TIP_ANCESTOR_SEARCH_DEPTH ,
126
127
cache_misses : 0 ,
128
+ #[ cfg( test) ]
127
129
no_cache : false ,
128
130
}
129
131
}
@@ -206,6 +208,17 @@ impl InvGenerator {
206
208
Ok ( None )
207
209
}
208
210
211
+ #[ cfg( not( test) ) ]
212
+ fn test_clear_cache ( & mut self ) { }
213
+
214
+ /// Clear the cache (test only)
215
+ #[ cfg( test) ]
216
+ fn test_clear_cache ( & mut self ) {
217
+ if self . no_cache {
218
+ self . processed_tenures . clear ( ) ;
219
+ }
220
+ }
221
+
209
222
/// Get a processed tenure. If it's not cached, then load it from disk.
210
223
///
211
224
/// Loading it is expensive, so once loaded, store it with the cached processed tenure map
@@ -287,9 +300,7 @@ impl InvGenerator {
287
300
self . cache_misses = self . cache_misses . saturating_add ( 1 ) ;
288
301
Ok ( loaded_info_opt)
289
302
} ;
290
- if self . no_cache {
291
- self . processed_tenures . clear ( ) ;
292
- }
303
+ self . test_clear_cache ( ) ;
293
304
ret
294
305
}
295
306
You can’t perform that action at this time.
0 commit comments