From 17df8bc797a73bac47a15c59aecd3beae33d11f8 Mon Sep 17 00:00:00 2001 From: Shawn Hurley Date: Mon, 10 Mar 2025 19:09:39 -0400 Subject: [PATCH] Removing for loops for the windows file content search * Seeing runs of kai on windows go from 2m6s to 1m20s * Still need a full solution but is better then it was before Signed-off-by: Shawn Hurley --- provider/internal/builtin/service_client.go | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/provider/internal/builtin/service_client.go b/provider/internal/builtin/service_client.go index 328c1ed0..96fbbbbd 100644 --- a/provider/internal/builtin/service_client.go +++ b/provider/internal/builtin/service_client.go @@ -599,14 +599,8 @@ func runOSSpecificGrepCommand(pattern string, location string, providerContext p psScript := ` $pattern = $env:PATTERN $location = $env:FILEPATH - Get-ChildItem -Path $location -Recurse -File | ForEach-Object { - $file = $_ - # Search for the pattern in the file - Select-String -Path $file.FullName -Pattern $pattern -AllMatches | ForEach-Object { - foreach ($match in $_.Matches) { - "{0}:{1}:{2}" -f $file.FullName, $_.LineNumber, $match.Value - } - } + Get-ChildItem -Path $location -Recurse | Select-String -Pattern $pattern -AllMatches | ForEach-Object { + "{0}:{1}:{2}" -f $_.Path, $_.LineNumber, $_.Line }` findstr := exec.Command(utilName, "-Command", psScript) findstr.Env = append(os.Environ(), "PATTERN="+pattern, "FILEPATH="+location)