♻️ kernel/search/find: modernize with wg.Go (#17289)

This commit is contained in:
iliya 2026-03-21 12:53:41 +09:00 committed by GitHub
parent 440f9e29ec
commit c3808f4e77
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -71,19 +71,15 @@ func FindAllMatches(root string, targets []string) []Match {
var collectWg sync.WaitGroup
var matches []Match
collectWg.Add(1)
go func() {
defer collectWg.Done()
collectWg.Go(func() {
for m := range results {
matches = append(matches, m)
}
}()
})
numWorkers := runtime.NumCPU()
for i := 0; i < numWorkers; i++ {
wg.Add(1)
go func() {
defer wg.Done()
for range numWorkers {
wg.Go(func() {
for p := range jobs {
hits := scanFileForTargets(p, patternIndex, maxLen)
if len(hits) > 0 {
@ -92,7 +88,7 @@ func FindAllMatches(root string, targets []string) []Match {
}
}
}
}()
})
}
_ = filepath.WalkDir(root, func(path string, d os.DirEntry, err error) error {