a73x

72b365b6

refactor(ignore): use slices.Contains and strings.SplitSeq

a73x   2026-04-29 05:53

Commit message
refactor(ignore): use slices.Contains and strings.SplitSeq

internal/ignore/ignore.go
Old New
@@ -3,6 +3,7 @@ package ignore
3 import ( 3 import (
4 "os" 4 "os"
5 "path/filepath" 5 "path/filepath"
6 "slices"
6 "strings" 7 "strings"
7 "sync" 8 "sync"
8 9
@@ -51,12 +52,9 @@ func (m *Matcher) ShouldIgnore(path string) bool {
51 if err != nil || strings.HasPrefix(rel, "..") { 52 if err != nil || strings.HasPrefix(rel, "..") {
52 return true 53 return true
53 } 54 }
54 parts := strings.Split(rel, string(filepath.Separator)) 55 for p := range strings.SplitSeq(rel, string(filepath.Separator)) {
55 for _, p := range parts { 56 if slices.Contains(hardExcludeDirs, p) {
56 for _, ex := range hardExcludeDirs { 57 return true
57 if p == ex {
58 return true
59 }
60 } 58 }
61 } 59 }
62 base := filepath.Base(rel) 60 base := filepath.Base(rel)