@@ -40,13 +40,13 @@ impl OptimizedScanner {
4040 }
4141 }
4242
43- /// Set maximum cache size
43+ /// Set cache size
4444 pub fn with_cache_size ( mut self , size : usize ) -> Self {
4545 self . max_cache_size = size;
4646 self
4747 }
4848
49- /// Gets the relevant detectors for a specific file extension
49+ /// Check if a file should be scanned based on size and type
5050 /// This optimizes performance by only running detectors that are likely to match
5151 fn get_relevant_detectors ( & self , path : & Path ) -> Vec < & dyn PatternDetector > {
5252 let ext = path. extension ( ) . and_then ( |e| e. to_str ( ) ) ;
@@ -56,19 +56,19 @@ impl OptimizedScanner {
5656 // For Rust files, prioritize Rust-specific detectors but include general ones
5757 self . detectors . iter ( ) . map ( |d| d. as_ref ( ) ) . collect ( )
5858 }
59- Some ( "js" ) | Some ( "ts" ) | Some ( "jsx" ) | Some ( "tsx" ) | Some ( "vue" ) | Some ( "svelte" ) => {
59+ Some ( "js" | "ts" | "jsx" | "tsx" | "vue" | "svelte" ) => {
6060 // For JS/TS files, include all detectors
6161 self . detectors . iter ( ) . map ( |d| d. as_ref ( ) ) . collect ( )
6262 }
63- Some ( "py" ) | Some ( "pyw" ) | Some ( "pyx" ) => {
63+ Some ( "py" | "pyw" | "pyx" ) => {
6464 // For Python files, include all detectors
6565 self . detectors . iter ( ) . map ( |d| d. as_ref ( ) ) . collect ( )
6666 }
6767 Some ( "java" ) => {
6868 // For Java files, include all detectors
6969 self . detectors . iter ( ) . map ( |d| d. as_ref ( ) ) . collect ( )
7070 }
71- Some ( "c" ) | Some ( "cpp" ) | Some ( "cc" ) | Some ( "cxx" ) | Some ( "h" ) | Some ( "hpp" ) => {
71+ Some ( "c" | "cpp" | "cc" | "cxx" | "h" | "hpp" ) => {
7272 // For C/C++ files, include all detectors
7373 self . detectors . iter ( ) . map ( |d| d. as_ref ( ) ) . collect ( )
7474 }
@@ -84,12 +84,11 @@ impl OptimizedScanner {
8484 // For Ruby files, include all detectors
8585 self . detectors . iter ( ) . map ( |d| d. as_ref ( ) ) . collect ( )
8686 }
87- Some ( "sh" ) | Some ( "bash" ) | Some ( "zsh" ) => {
87+ Some ( "sh" | "bash" | "zsh" ) => {
8888 // For shell scripts, include all detectors
8989 self . detectors . iter ( ) . map ( |d| d. as_ref ( ) ) . collect ( )
9090 }
91- Some ( "json" ) | Some ( "yaml" ) | Some ( "yml" ) | Some ( "toml" ) | Some ( "xml" )
92- | Some ( "ini" ) | Some ( "cfg" ) => {
91+ Some ( "json" | "yaml" | "yml" | "toml" | "xml" | "ini" | "cfg" ) => {
9392 // For config files, include general detectors (TODO, FIXME, etc.)
9493 self . detectors . iter ( ) . map ( |d| d. as_ref ( ) ) . collect ( )
9594 }
@@ -331,24 +330,17 @@ impl StreamingScanner {
331330
332331 match ext {
333332 Some ( "rs" ) => self . detectors . iter ( ) . map ( |d| d. as_ref ( ) ) . collect ( ) ,
334- Some ( "js" ) | Some ( "ts" ) | Some ( "jsx" ) | Some ( "tsx" ) | Some ( "vue" ) | Some ( "svelte" ) => {
333+ Some ( "js" | "ts" | "jsx" | "tsx" | "vue" | "svelte" ) => {
335334 self . detectors . iter ( ) . map ( |d| d. as_ref ( ) ) . collect ( )
336335 }
337- Some ( "py" ) | Some ( "pyw" ) | Some ( "pyx" ) => {
336+ Some ( "py" | "pyw" | "pyx" ) => self . detectors . iter ( ) . map ( |d| d. as_ref ( ) ) . collect ( ) ,
337+ Some ( "c" | "cpp" | "cc" | "cxx" | "h" | "hpp" ) => {
338338 self . detectors . iter ( ) . map ( |d| d. as_ref ( ) ) . collect ( )
339339 }
340- Some ( "java" ) => self . detectors . iter ( ) . map ( |d| d. as_ref ( ) ) . collect ( ) ,
341- Some ( "c" ) | Some ( "cpp" ) | Some ( "cc" ) | Some ( "cxx" ) | Some ( "h" ) | Some ( "hpp" ) => {
342- self . detectors . iter ( ) . map ( |d| d. as_ref ( ) ) . collect ( )
343- }
344- Some ( "go" ) => self . detectors . iter ( ) . map ( |d| d. as_ref ( ) ) . collect ( ) ,
345- Some ( "php" ) => self . detectors . iter ( ) . map ( |d| d. as_ref ( ) ) . collect ( ) ,
346- Some ( "rb" ) => self . detectors . iter ( ) . map ( |d| d. as_ref ( ) ) . collect ( ) ,
347- Some ( "sh" ) | Some ( "bash" ) | Some ( "zsh" ) => {
340+ Some ( "sh" | "bash" | "zsh" ) => self . detectors . iter ( ) . map ( |d| d. as_ref ( ) ) . collect ( ) ,
341+ Some ( "json" | "yaml" | "yml" | "toml" | "xml" | "ini" | "cfg" ) => {
348342 self . detectors . iter ( ) . map ( |d| d. as_ref ( ) ) . collect ( )
349343 }
350- Some ( "json" ) | Some ( "yaml" ) | Some ( "yml" ) | Some ( "toml" ) | Some ( "xml" )
351- | Some ( "ini" ) | Some ( "cfg" ) => self . detectors . iter ( ) . map ( |d| d. as_ref ( ) ) . collect ( ) ,
352344 _ => self . detectors . iter ( ) . map ( |d| d. as_ref ( ) ) . collect ( ) ,
353345 }
354346 }
@@ -546,22 +538,18 @@ impl AdvancedScanner {
546538
547539 match ext {
548540 Some ( "rs" ) => self . detectors . iter ( ) . map ( |d| d. as_ref ( ) ) . collect ( ) ,
549- Some ( "js" ) | Some ( "ts" ) | Some ( "jsx" ) | Some ( "tsx" ) | Some ( "vue" ) | Some ( "svelte" ) => {
550- self . detectors . iter ( ) . map ( |d| d. as_ref ( ) ) . collect ( )
551- }
552- Some ( "py" ) | Some ( "pyw" ) | Some ( "pyx" ) => {
541+ Some ( "js" | "ts" | "jsx" | "tsx" | "vue" | "svelte" ) => {
553542 self . detectors . iter ( ) . map ( |d| d. as_ref ( ) ) . collect ( )
554543 }
544+ Some ( "py" | "pyw" | "pyx" ) => self . detectors . iter ( ) . map ( |d| d. as_ref ( ) ) . collect ( ) ,
555545 Some ( "java" ) => self . detectors . iter ( ) . map ( |d| d. as_ref ( ) ) . collect ( ) ,
556- Some ( "c" ) | Some ( "cpp" ) | Some ( "cc" ) | Some ( "cxx" ) | Some ( "h" ) | Some ( "hpp" ) => {
546+ Some ( "c" | "cpp" | "cc" | "cxx" | "h" | "hpp" ) => {
557547 self . detectors . iter ( ) . map ( |d| d. as_ref ( ) ) . collect ( )
558548 }
559549 Some ( "go" ) => self . detectors . iter ( ) . map ( |d| d. as_ref ( ) ) . collect ( ) ,
560550 Some ( "php" ) => self . detectors . iter ( ) . map ( |d| d. as_ref ( ) ) . collect ( ) ,
561551 Some ( "rb" ) => self . detectors . iter ( ) . map ( |d| d. as_ref ( ) ) . collect ( ) ,
562- Some ( "sh" ) | Some ( "bash" ) | Some ( "zsh" ) => {
563- self . detectors . iter ( ) . map ( |d| d. as_ref ( ) ) . collect ( )
564- }
552+ Some ( "sh" | "bash" | "zsh" ) => self . detectors . iter ( ) . map ( |d| d. as_ref ( ) ) . collect ( ) ,
565553 Some ( "json" ) | Some ( "yaml" ) | Some ( "yml" ) | Some ( "toml" ) | Some ( "xml" )
566554 | Some ( "ini" ) | Some ( "cfg" ) => self . detectors . iter ( ) . map ( |d| d. as_ref ( ) ) . collect ( ) ,
567555 _ => self . detectors . iter ( ) . map ( |d| d. as_ref ( ) ) . collect ( ) ,
0 commit comments