summaryrefslogtreecommitdiff
path: root/commit.c
diff options
context:
space:
mode:
authorMarco Costalba <mcostalba@gmail.com>2007-07-22 10:23:05 +0200
committerJunio C Hamano <gitster@pobox.com>2007-07-22 01:40:21 -0700
commitc4640fe8d9e25fd3e206a39233c71a6dbb68917e (patch)
tree5ef0602a6f3405f89f769f55017dac4df25a55b5 /commit.c
parente5633cbb8577b430f175f62cf4e7ed53f2434a89 (diff)
downloadgit-c4640fe8d9e25fd3e206a39233c71a6dbb68917e.tar.gz
Avoid to duplicate commit message when is not encoded
When a commit message doesn't have encoding information and encoding output is utf-8 (default) then an useless xstrdup() of commit message is done. If we assume most of users live in an utf-8 world, this useless copy is the common case. Performance issue found with KCachegrind. Signed-off-by: Marco Costalba <mcostalba@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'commit.c')
-rw-r--r--commit.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/commit.c b/commit.c
index 4c5dfa9af0..dc5a0643f3 100644
--- a/commit.c
+++ b/commit.c
@@ -721,7 +721,10 @@ static char *logmsg_reencode(const struct commit *commit,
encoding = get_header(commit, "encoding");
use_encoding = encoding ? encoding : utf8;
if (!strcmp(use_encoding, output_encoding))
- out = xstrdup(commit->buffer);
+ if (encoding) /* we'll strip encoding header later */
+ out = xstrdup(commit->buffer);
+ else
+ return NULL; /* nothing to do */
else
out = reencode_string(commit->buffer,
output_encoding, use_encoding);