{"thread":{"id":"9134","subject":"[PATCH] Avoid to duplicate commit message when is not encoded","startedAt":"2007-07-22T08:23:05Z","lastAt":"2007-07-22T22:04:33Z","messageCount":5,"participants":["Marco Costalba","Junio C Hamano","Alex Riesen"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"48106","messageId":"e5bfff550707220123g5826cbf5n3e2ff7256d9b5366@mail.gmail.com","threadId":"9134","inReplyTo":null,"subject":"[PATCH] Avoid to duplicate commit message when is not encoded","fromName":"Marco Costalba","fromEmail":"mcostalba@gmail.com","sentAt":"2007-07-22T08:23:05Z","receivedAt":"2007-07-22T08:23:05Z","isPatch":true,"sender":{"key":"mcostalba@gmail.com","avatar":null},"body":"When a commit message doesn't have encoding information\nand encoding output is utf-8 (default) then an useless\nxstrdup() of commit message is done.\n\nIf we assume most of users live in an utf-8 world, this\nuseless copy is the common case.\n\nPerformance issue found with KCachegrind.\n\nSigned-off-by: Marco Costalba <mcostalba@gmail.com>\n---\n commit.c |    5 ++++-\n 1 files changed, 4 insertions(+), 1 deletions(-)\n\ndiff --git a/commit.c b/commit.c\nindex 4c5dfa9..ba8413b 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -721,7 +721,10 @@ static char *logmsg_reencode(const\n \tencoding = get_header(commit, \"encoding\");\n \tuse_encoding = encoding ? encoding : utf8;\n  \tif (!strcmp(use_encoding, output_encoding))\n-\t\tout = xstrdup(commit->buffer);\n+\t\tif (encoding) // we'll strip encoding header later\n+\t\t\tout = xstrdup(commit->buffer);\n+\t\telse\n+\t\t\treturn NULL; // nothing to do\n \telse\n \t\tout = reencode_string(commit->buffer,\n \t\t\t\t      output_encoding, use_encoding);\n-- \n1.5.3.rc2.23.g4c77-dirty\n"},{"id":"48107","messageId":"7vd4yksuer.fsf@assigned-by-dhcp.cox.net","threadId":"9134","inReplyTo":"e5bfff550707220123g5826cbf5n3e2ff7256d9b5366@mail.gmail.com","subject":"Re: [PATCH] Avoid to duplicate commit message when is not encoded","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-07-22T08:40:44Z","receivedAt":"2007-07-22T08:40:44Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Thanks.\n"},{"id":"48112","messageId":"20070722085225.GB3408@steel.home","threadId":"9134","inReplyTo":"e5bfff550707220123g5826cbf5n3e2ff7256d9b5366@mail.gmail.com","subject":"Re: [PATCH] Avoid to duplicate commit message when is not encoded","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2007-07-22T08:52:25Z","receivedAt":"2007-07-22T08:52:25Z","isPatch":true,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"Marco Costalba, Sun, Jul 22, 2007 10:23:05 +0200:\n> +\t\tif (encoding) // we'll strip encoding header later\n\nYou better avoid using C++ comments, not all C compilers support them.\n\n> +\t\telse\n> +\t\t\treturn NULL; // nothing to do\n\nAnd you better avoid such useless comments too\n"},{"id":"48114","messageId":"7v4pjwssp0.fsf@assigned-by-dhcp.cox.net","threadId":"9134","inReplyTo":"20070722085225.GB3408@steel.home","subject":"Re: [PATCH] Avoid to duplicate commit message when is not encoded","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-07-22T09:17:47Z","receivedAt":"2007-07-22T09:17:47Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Alex Riesen <raa.lkml@gmail.com> writes:\n\n> Marco Costalba, Sun, Jul 22, 2007 10:23:05 +0200:\n>> +\t\tif (encoding) // we'll strip encoding header later\n>\n> You better avoid using C++ comments, not all C compilers support them.\n\nI've \"fixed\" them.\n\n>> +\t\telse\n>> +\t\t\treturn NULL; // nothing to do\n>\n> And you better avoid such useless comments too\n\nI think this one is probably a good-to-have.  It really needs a\nbit of thinking why there is nothing to do in this case.  At\nleast for me it did ;-)\n"},{"id":"48206","messageId":"e5bfff550707221504g395580e6jdde1f37a810302f0@mail.gmail.com","threadId":"9134","inReplyTo":"7v4pjwssp0.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] Avoid to duplicate commit message when is not encoded","fromName":"Marco Costalba","fromEmail":"mcostalba@gmail.com","sentAt":"2007-07-22T22:04:33Z","receivedAt":"2007-07-22T22:04:33Z","isPatch":true,"sender":{"key":"mcostalba@gmail.com","avatar":null},"body":"On 7/22/07, Junio C Hamano <gitster@pobox.com> wrote:\n> Alex Riesen <raa.lkml@gmail.com> writes:\n>\n> > Marco Costalba, Sun, Jul 22, 2007 10:23:05 +0200:\n> >> +            if (encoding) // we'll strip encoding header later\n> >\n> > You better avoid using C++ comments, not all C compilers support them.\n>\n> I've \"fixed\" them.\n>\n\nSorry, I wrote them automatically without thinking it is better to\navoid them in C. BTW I would think it's more about coding style then\ncompiler support.\n\n> >> +            else\n> >> +                    return NULL; // nothing to do\n> >\n> > And you better avoid such useless comments too\n>\n> I think this one is probably a good-to-have.  It really needs a\n> bit of thinking why there is nothing to do in this case.  At\n> least for me it did ;-)\n>\n\nMe too ;-)\n"}]}