From 5a37bf3beb65e554a1066def4ca9fea3107298a7 Mon Sep 17 00:00:00 2001 From: Seednode Date: Tue, 3 Oct 2023 11:07:58 -0500 Subject: [PATCH] Exit early from path validation if checks pass, instead of completing the loop --- cmd/files.go | 5 +++++ cmd/root.go | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/cmd/files.go b/cmd/files.go index ed99fed..634aff9 100644 --- a/cmd/files.go +++ b/cmd/files.go @@ -177,6 +177,8 @@ func pathIsValid(path string, paths []string) bool { for i := 0; i < len(paths); i++ { if strings.HasPrefix(path, paths[i]) { matchesPrefix = true + + break } } @@ -306,6 +308,7 @@ func walkPath(path string, fileChannel chan<- string, stats *scanStatsChannels, go func() { wg.Wait() + done <- true }() @@ -366,6 +369,7 @@ func scanPaths(paths []string, sort string, index *fileIndex, formats *types.Typ go func() { wg.Wait() + done <- true }() @@ -391,6 +395,7 @@ Poll: if stats.filesMatched < 1 { fmt.Println("No files matched") + return []string{}, nil } diff --git a/cmd/root.go b/cmd/root.go index 07498e5..87870f1 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -12,7 +12,7 @@ import ( ) const ( - ReleaseVersion string = "2.3.0" + ReleaseVersion string = "2.3.1" ) var (