From 4c873f8d0cf5638e0271f2f2fcfd60007fcc414c Mon Sep 17 00:00:00 2001 From: Julie Tibshirani Date: Wed, 21 Feb 2024 08:43:58 -0800 Subject: [PATCH] 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. --- cmd/searcher/internal/search/search_regex.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/searcher/internal/search/search_regex.go b/cmd/searcher/internal/search/search_regex.go index e7a8a51fea8..5f0c5756370 100644 --- a/cmd/searcher/internal/search/search_regex.go +++ b/cmd/searcher/internal/search/search_regex.go @@ -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 {