path: root/strbuf.h
diff options
authorRené Scharfe <>2007-11-10 11:14:20 (GMT)
committerJunio C Hamano <>2007-11-11 10:04:46 (GMT)
commitf29d59586c2a1666d18776cca5d96752dec0e8a2 (patch)
tree3e04780d3131bfada78a173eced2063280b2761d /strbuf.h
parentcde75e59e1b2d8dd3ba49bc9034692dd06ee3907 (diff)
--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 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 <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'strbuf.h')
0 files changed, 0 insertions, 0 deletions