Skip to content

Commit

Permalink
Compile File regex for snap globally, to speed up walking
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 659482371
  • Loading branch information
vpasdf authored and copybara-github committed Aug 5, 2024
1 parent 6d8f831 commit 55b9199
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions extractor/filesystem/os/snap/extractor.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,11 @@ func (e Extractor) Name() string { return Name }
// Version of the extractor.
func (e Extractor) Version() int { return 0 }

// the yaml file is found in snap/<app>/<revision>/meta/snap.yaml
var filePathRegex = regexp.MustCompile(`^snap/[^/]*/[^/]*/meta/snap.yaml$`)

// FileRequired returns true if the specified file matches snap.yaml file pattern.
func (e Extractor) FileRequired(path string, fileinfo fs.FileInfo) bool {
// the yaml file is found in snap/<app>/<revision>/meta/snap.yaml
filePathRegex := regexp.MustCompile(`^snap/[^/]*/[^/]*/meta/snap.yaml$`)
if match := filePathRegex.FindString(path); match == "" {
return false
}
Expand Down

0 comments on commit 55b9199

Please sign in to comment.