提交 c4640fe8 编写于 作者: M Marco Costalba 提交者: Junio C Hamano

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: NMarco Costalba <mcostalba@gmail.com>
Signed-off-by: NJunio C Hamano <gitster@pobox.com>
上级 e5633cbb
......@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册