Reduce regexp compilation overhead
When using an exclusion pattern only compile it once at the start of a
directory traversal instead of once per item in the walk.
@@ -181,16 +181,16 @@ func walkDirectory(toWalk string, blackList []string, extensionLookup map[string
extension := ""
var filejobs []FileJob
- godirwalk.Walk(toWalk, &godirwalk.Options{
- // Unsorted is meant to make the walk faster and we need to sort after processing anyway
- Unsorted: true,
- Callback: func(root string, info *godirwalk.Dirent) error {
-
var regex *regexp.Regexp
if Exclude != "" {
regex = regexp.MustCompile(Exclude)
}
+ godirwalk.Walk(toWalk, &godirwalk.Options{
+ // Unsorted is meant to make the walk faster and we need to sort after processing anyway
+ Unsorted: true,
+ Callback: func(root string, info *godirwalk.Dirent) error {
+
if Exclude != "" {
if regex.Match([]byte(info.Name())) {
if Verbose {
