Skip to content

Commit 424b048

Browse files
committed
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
1 parent 53bcb73 commit 424b048

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

commit.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ func commitsCount(repoPath, revision, relpath string) (int64, error) {
142142
}
143143

144144
if isFallback {
145-
return int64(len(strings.Split(stdout, "\n"))), nil
145+
return int64(strings.Count(stdout, "\n")), nil
146146
}
147147
return strconv.ParseInt(strings.TrimSpace(stdout), 10, 64)
148148
}

0 commit comments

Comments
 (0)