k3s/vendor/github.com/monochromegane/go-gitignore/full_scan_patterns.go

32 lines
601 B
Go

package gitignore
import "strings"
// Only benchmark use
type fullScanPatterns struct {
absolute patterns
relative patterns
}
func newFullScanPatterns() *fullScanPatterns {
return &fullScanPatterns{
absolute: patterns{},
relative: patterns{},
}
}
func (ps *fullScanPatterns) add(pattern string) {
if strings.HasPrefix(pattern, "/") {
ps.absolute.add(newPattern(pattern))
} else {
ps.relative.add(newPattern(pattern))
}
}
func (ps fullScanPatterns) match(path string, isDir bool) bool {
if ps.absolute.match(path, isDir) {
return true
}
return ps.relative.match(path, isDir)
}