1
0
mirror of https://github.com/go-gitea/git.git synced 2026-02-05 06:45:03 +01:00

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
This commit is contained in:
Sandro Santilli
2016-08-31 00:43:15 +02:00
parent 53bcb7352f
commit 424b048ee6

View File

@@ -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)
}