summaryrefslogtreecommitdiff
path: root/utf8.h
diff options
context:
space:
mode:
authorRené Scharfe <rene.scharfe@lsrfire.ath.cx>2010-02-19 22:20:44 (GMT)
committerJunio C Hamano <gitster@pobox.com>2010-02-20 17:22:44 (GMT)
commit462749b728f72079a67202d4d0d1ef19ef993f61 (patch)
treed88473ea817cf1c86f8cd3f51c906ef3cccd34f5 /utf8.h
parent68ad5e1e9c10e8a640703aadbdf8b8366014373b (diff)
downloadgit-462749b728f72079a67202d4d0d1ef19ef993f61.zip
git-462749b728f72079a67202d4d0d1ef19ef993f61.tar.gz
git-462749b728f72079a67202d4d0d1ef19ef993f61.tar.bz2
utf8.c: speculatively assume utf-8 in strbuf_add_wrapped_text()
is_utf8() works by calling utf8_width() for each character at the supplied location. In strbuf_add_wrapped_text(), we do that anyway while wrapping the lines. So instead of checking the encoding beforehand, optimistically assume that it's utf-8 and wrap along until an invalid character is hit, and when that happens start over. This pays off if the text consists only of valid utf-8 characters. The following command was run against the Linux kernel repo with git 1.7.0: $ time git log --format='%b' v2.6.32 >/dev/null real 0m2.679s user 0m2.580s sys 0m0.100s $ time git log --format='%w(60,4,8)%b' >/dev/null real 0m4.342s user 0m4.230s sys 0m0.110s And with this patch series: $ time git log --format='%w(60,4,8)%b' >/dev/null real 0m3.741s user 0m3.630s sys 0m0.110s So the cost of wrapping is reduced to 70% in this case. Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'utf8.h')
0 files changed, 0 insertions, 0 deletions