Skip to content

Commit

Permalink
Avoid to duplicate commit message when is not encoded
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Marco Costalba authored and Junio C Hamano committed Jul 22, 2007
1 parent e5633cb commit c4640fe
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion commit.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit c4640fe

Please sign in to comment.