Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 4 additions & 12 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,9 @@ func run() (bool, error) {
eg.Go(func() error {
var wg sync.WaitGroup
for i := 0; i < g.numWorkersFileScanner; i++ {
wg.Add(1)
go func() {
defer wg.Done()
wg.Go(func() {
g.worker()
}()
})
}
wg.Wait()
close(g.results)
Expand Down Expand Up @@ -263,10 +261,7 @@ func (g *grepper) walk() error {
}
// For N >= 1, fastwalk's MaxDepth=N already aligns with ripgrep's -d N
// (root dir counts as one level in both). Negative means unset → unlimited.
fwMaxDepth := 0
if g.maxDepth > 0 {
fwMaxDepth = g.maxDepth
}
fwMaxDepth := max(g.maxDepth, 0)
cfg := &fastwalk.Config{NumWorkers: g.numWorkersDirWalker, MaxDepth: fwMaxDepth}
err := fastwalk.Walk(cfg, g.root, func(path string, d fs.DirEntry, err error) error {
if g.ctx.Err() != nil {
Expand Down Expand Up @@ -377,10 +372,7 @@ func (g *grepper) scanFile(path string) []byte {
// scanWholeBody finds matches by sliding bytes.Index over data. Cheap when a
// file has no matches at all — one bytes.Index call returns -1 and we're done.
func (g *grepper) scanWholeBody(path string, data []byte) []byte {
headLimit := len(data)
if headLimit > peekSize {
headLimit = peekSize
}
headLimit := min(len(data), peekSize)
if bytes.IndexByte(data[:headLimit], 0) >= 0 {
return nil
}
Expand Down