From: "Marco Costalba" <mcostalba@gmail.com>
To: "Junio C Hamano" <gitster@pobox.com>
Cc: "Git Mailing List" <git@vger.kernel.org>
Subject: [PATCH] Avoid to duplicate commit message when is not encoded
Date: Sun, 22 Jul 2007 10:23:05 +0200 [thread overview]
Message-ID: <e5bfff550707220123g5826cbf5n3e2ff7256d9b5366@mail.gmail.com> (raw)
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>
---
commit.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/commit.c b/commit.c
index 4c5dfa9..ba8413b 100644
--- a/commit.c
+++ b/commit.c
@@ -721,7 +721,10 @@ static char *logmsg_reencode(const
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);
--
1.5.3.rc2.23.g4c77-dirty
next reply other threads:[~2007-07-22 8:23 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-22 8:23 Marco Costalba [this message]
2007-07-22 8:40 ` [PATCH] Avoid to duplicate commit message when is not encoded Junio C Hamano
2007-07-22 8:52 ` Alex Riesen
2007-07-22 9:17 ` Junio C Hamano
2007-07-22 22:04 ` Marco Costalba
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e5bfff550707220123g5826cbf5n3e2ff7256d9b5366@mail.gmail.com \
--to=mcostalba@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).