Skip to content

Avoid creating an array for the sole purpose of counting elements #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 31, 2016

Conversation

strk
Copy link
Contributor

@strk strk commented Aug 30, 2016

Probably speeds up counting commits for git versions < 1.8.0,
although I dubt it would make a visible difference

Probably speeds up counting commits for git versions < 1.8.0,
although I dubt it would make a visible difference
@@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you verify that the result is actually correct? I guess this will be 1 smaller than the actual.

Copy link
Contributor Author

@strk strk Aug 31, 2016 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With format='' the output does not end with a newline (checked)
@unknwon
Copy link
Member

unknwon commented Aug 31, 2016

Thanks!

@unknwon unknwon merged commit 2ef563c into gogs:master Aug 31, 2016
sapk pushed a commit to sapk-fork/git-module that referenced this pull request Mar 8, 2017
Added real name of Bwko to maintainers file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants