@@ -93,7 +93,7 @@ pub struct Scanner {
93
93
dirs : Vec < PathBuf > ,
94
94
95
95
/// All generated globs, used for setting up watchers
96
- globs : Vec < GlobEntry > ,
96
+ globs : Option < Vec < GlobEntry > > ,
97
97
98
98
/// Track unique set of candidates
99
99
candidates : FxHashSet < String > ,
@@ -296,16 +296,24 @@ impl Scanner {
296
296
297
297
#[ tracing:: instrument( skip_all) ]
298
298
pub fn get_globs ( & mut self ) -> Vec < GlobEntry > {
299
+ if let Some ( globs) = & self . globs {
300
+ return globs. clone ( ) ;
301
+ }
302
+
299
303
self . scan_sources ( ) ;
300
304
305
+ let mut globs = vec ! [ ] ;
301
306
for source in self . sources . iter ( ) {
302
307
match source {
303
308
SourceEntry :: Auto { base } | SourceEntry :: External { base } => {
304
- let globs = resolve_globs ( ( base) . to_path_buf ( ) , & self . dirs , & self . extensions ) ;
305
- self . globs . extend ( globs) ;
309
+ globs. extend ( resolve_globs (
310
+ ( base) . to_path_buf ( ) ,
311
+ & self . dirs ,
312
+ & self . extensions ,
313
+ ) ) ;
306
314
}
307
315
SourceEntry :: Pattern { base, pattern } => {
308
- self . globs . push ( GlobEntry {
316
+ globs. push ( GlobEntry {
309
317
base : base. to_string_lossy ( ) . to_string ( ) ,
310
318
pattern : pattern. to_string ( ) ,
311
319
} ) ;
@@ -315,9 +323,12 @@ impl Scanner {
315
323
}
316
324
317
325
// Re-optimize the globs to reduce the number of patterns we have to scan.
318
- self . globs = optimize_patterns ( & self . globs ) ;
326
+ globs = optimize_patterns ( & globs) ;
327
+
328
+ // Track the globs for subsequent calls
329
+ self . globs = Some ( globs. clone ( ) ) ;
319
330
320
- self . globs . clone ( )
331
+ globs
321
332
}
322
333
323
334
#[ tracing:: instrument( skip_all) ]
0 commit comments