Skip to content

Commit 4e1d1a2

Browse files
peffgitster
authored andcommitted
shortlog: optimize "--summary" mode
If the user asked us only to show counts for each author, rather than the individual summary lines, then there is no point in us generating the summaries only to throw them away. With this patch, I measured the following speedup for "git shortlog -ns HEAD" on linux.git (best-of-five): [before] real 0m5.644s user 0m5.472s sys 0m0.176s [after] real 0m5.257s user 0m5.104s sys 0m0.156s That's only ~7%, but it's so easy to do, there's no good reason not to. We don't have to touch any downstream code, since we already fill in the magic string "<none>" to handle commits without a message. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2db6b83 commit 4e1d1a2

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

builtin/shortlog.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,12 @@ void shortlog_add_commit(struct shortlog *log, struct commit *commit)
132132
goto out;
133133
}
134134

135-
if (log->user_format)
136-
pretty_print_commit(&ctx, commit, &oneline);
137-
else
138-
format_commit_message(commit, "%s", &oneline, &ctx);
135+
if (!log->summary) {
136+
if (log->user_format)
137+
pretty_print_commit(&ctx, commit, &oneline);
138+
else
139+
format_commit_message(commit, "%s", &oneline, &ctx);
140+
}
139141

140142
insert_one_record(log, author.buf, oneline.len ? oneline.buf : "<none>");
141143

0 commit comments

Comments
 (0)