diff options
author | René Scharfe <rene.scharfe@lsrfire.ath.cx> | 2007-11-10 12:14:20 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2007-11-11 02:04:46 -0800 |
commit | f29d59586c2a1666d18776cca5d96752dec0e8a2 (patch) | |
tree | 3e04780d3131bfada78a173eced2063280b2761d /strbuf.c | |
parent | cde75e59e1b2d8dd3ba49bc9034692dd06ee3907 (diff) | |
download | git-f29d59586c2a1666d18776cca5d96752dec0e8a2.tar.gz |
--pretty=format: parse commit message only once
As Jeff King pointed out, some placeholder expansions are related to
each other: the steps to calculate one go most of the way towards
calculating the other, too.
This patch makes format_commit_message() parse the commit message
only once, remembering the position of each item. This speeds up
handling of format strings containing multiple placeholders from the
set %s, %a*, %c*, %e, %b.
Here are the timings for the git version in next. The first one is
to estimate the overhead of the caching, the second one is taken
from http://svn.tue.mpg.de/tentakel/trunk/tentakel/Makefile as an
example of a format string found in the wild. The times are the
fastest of three consecutive runs in each case:
$ time git log --pretty=format:%e >/dev/null
real 0m0.381s
user 0m0.340s
sys 0m0.024s
$ time git log --pretty=format:"* %cd %cn%n%n%s%n%b" >/dev/null
real 0m0.623s
user 0m0.556s
sys 0m0.052s
And here the times with this patch:
$ time git log --pretty=format:%e >/dev/null
real 0m0.385s
user 0m0.332s
sys 0m0.040s
$ time git log --pretty=format:"* %cd %cn%n%n%s%n%b" >/dev/null
real 0m0.563s
user 0m0.504s
sys 0m0.048s
Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'strbuf.c')
0 files changed, 0 insertions, 0 deletions