From 424b048ee6e45611a2ad5b186693c600adb3b627 Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Wed, 31 Aug 2016 00:43:15 +0200 Subject: [PATCH] Avoid creating an array for the sole purpose of counting elements Probably speeds up counting commits for git versions < 1.8.0, although I dubt it would make a visible difference --- commit.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commit.go b/commit.go index a7a205c..adde7ed 100644 --- a/commit.go +++ b/commit.go @@ -142,7 +142,7 @@ func commitsCount(repoPath, revision, relpath string) (int64, error) { } if isFallback { - return int64(len(strings.Split(stdout, "\n"))), nil + return int64(strings.Count(stdout, "\n")), nil } return strconv.ParseInt(strings.TrimSpace(stdout), 10, 64) }