Searcher: fix optimization for empty patterns (#60646)

In #59331, we refactored the searcher logic to support AND/ OR patterns in
searcher. While doing so, we accidentally regressed on an optimization that
avoids loading file content when the pattern is empty.

We now have a benchmark for empty patterns, but this benchmark was added
recently and wasn't run during that refactor.
This commit is contained in:
Julie Tibshirani 2024-02-21 08:43:58 -08:00 committed by GitHub
parent cd8624b604
commit 4c873f8d0c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -147,7 +147,7 @@ func regexSearch(
}
if !match && patternMatchesContent {
if _, ok := m.(allMatchTree); ok {
if _, ok := m.(*allMatchTree); ok {
// Avoid loading the file if this pattern always matches
match = true
} else {