@@ -18,36 +18,37 @@ var searchToFileMatchesCache = map[string][]string{}
18
18
var searchToFileMatchesCacheMutex = sync.Mutex {}
19
19
20
20
func FindFiles (query string ) chan * gocodewalker.File {
21
- searchToFileMatchesCacheMutex .Lock ()
22
- defer searchToFileMatchesCacheMutex .Unlock ()
23
-
24
- // get the keys for the cache
25
- var keys []string
26
- for k := range searchToFileMatchesCache {
27
- keys = append (keys , k )
28
- }
29
-
30
- // clear from the cache anything longer than the search since its will not help us
31
- for _ , k := range keys {
32
- if len (k ) > len (query ) || query [0 ] != k [0 ] { // if cached is longer OR the first char does not match...
33
- delete (searchToFileMatchesCache , k )
34
- }
35
- }
36
-
37
- // check if the files we expect are in the cache...
38
- files := make (chan * gocodewalker.File , 100000 )
39
- for i := len (query ); i > 0 ; i -- {
40
- r , ok := searchToFileMatchesCache [query [:i ]]
41
- if ok {
42
- go func () {
43
- for _ , f := range r {
44
- files <- & gocodewalker.File {Location : f }
45
- }
46
- close (files )
47
- }()
48
- return files
49
- }
50
- }
21
+ // TODO enable this again as it seems to have issues
22
+ //searchToFileMatchesCacheMutex.Lock()
23
+ //defer searchToFileMatchesCacheMutex.Unlock()
24
+ //
25
+ //// get the keys for the cache
26
+ //var keys []string
27
+ //for k := range searchToFileMatchesCache {
28
+ // keys = append(keys, k)
29
+ //}
30
+ //
31
+ //// clear from the cache anything longer than the search since its will not help us
32
+ //for _, k := range keys {
33
+ // if len(k) > len(query) || query[0] != k[0] { // if cached is longer OR the first char does not match...
34
+ // delete(searchToFileMatchesCache, k)
35
+ // }
36
+ //}
37
+ //
38
+ //// check if the files we expect are in the cache...
39
+ //files := make(chan *gocodewalker.File, 100000)
40
+ //for i := len(query); i > 0; i-- {
41
+ // r, ok := searchToFileMatchesCache[query[:i]]
42
+ // if ok {
43
+ // go func() {
44
+ // for _, f := range r {
45
+ // files <- &gocodewalker.File{Location: f}
46
+ // }
47
+ // close(files)
48
+ // }()
49
+ // return files
50
+ // }
51
+ //}
51
52
52
53
return walkFiles ()
53
54
}
0 commit comments