@@ -38,14 +38,16 @@ func newRegexCache() *regexCache {
39// get retrieves a compiled regex from cache or compiles and caches it
39// get retrieves a compiled regex from cache or compiles and caches it
40func (rc *regexCache) get(pattern string) (*regexp.Regexp, error) {
40func (rc *regexCache) get(pattern string) (*regexp.Regexp, error) {
41− var rerr error
41+ re, ok := rc.Get(pattern)
42− return rc.GetOrSet(pattern, func() *regexp.Regexp {
42+ if ok && re != nil {
43− regex, err := regexp.Compile(pattern)
45+ re, err := regexp.Compile(pattern)
44− if err != nil {
46+ if err != nil {
45− rerr = err
47+ return nil, err
47− return regex
49+ rc.Set(pattern, re)
48− }), rerr
50+ return re, nil
51// ResetCache clears compiled regex caches to prevent unbounded growth across sessions.
53// ResetCache clears compiled regex caches to prevent unbounded growth across sessions.
@@ -339,6 +341,9 @@ func searchFilesWithRegex(pattern, rootPath, include string) ([]grepMatch, error
341func fileContainsPattern(filePath string, pattern *regexp.Regexp) (bool, int, int, string, error) {
343func fileContainsPattern(filePath string, pattern *regexp.Regexp) (bool, int, int, string, error) {
345+ return false, 0, 0, "", nil
342 // Only search text files.
347 // Only search text files.
343 if !isTextFile(filePath) {
348 if !isTextFile(filePath) {
344 return false, 0, 0, "", nil
349 return false, 0, 0, "", nil