]> git.ipfire.org Git - thirdparty/git.git/commitdiff
shortlog: optimize "--summary" mode
authorJeff King <peff@peff.net>
Mon, 18 Jan 2016 20:02:52 +0000 (15:02 -0500)
committerJunio C Hamano <gitster@pobox.com>
Tue, 19 Jan 2016 17:55:01 +0000 (09:55 -0800)
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 <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/shortlog.c

index 1261ec4dd07fea6228ba3a3bc3a0b9b2bf6cde10..973b50d417753618da50b9d74d290280bc914ff7 100644 (file)
@@ -132,10 +132,12 @@ void shortlog_add_commit(struct shortlog *log, struct commit *commit)
                goto out;
        }
 
-       if (log->user_format)
-               pretty_print_commit(&ctx, commit, &oneline);
-       else
-               format_commit_message(commit, "%s", &oneline, &ctx);
+       if (!log->summary) {
+               if (log->user_format)
+                       pretty_print_commit(&ctx, commit, &oneline);
+               else
+                       format_commit_message(commit, "%s", &oneline, &ctx);
+       }
 
        insert_one_record(log, author.buf, oneline.len ? oneline.buf : "<none>");