From: Junio C Hamano <gitster@pobox.com>
To: Mike Hommey <mh@glandium.org>
Cc: "André Goddard Rosa" <andre.goddard@gmail.com>,
"Git Mailing List" <git@vger.kernel.org>
Subject: Re: [PATCH] Avoid recalculating filename string pointer.
Date: Thu, 22 Nov 2007 12:21:04 -0800 [thread overview]
Message-ID: <7voddm3ubz.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <20071122195457.GB19675@glandium.org> (Mike Hommey's message of "Thu, 22 Nov 2007 20:54:57 +0100")
Mike Hommey <mh@glandium.org> writes:
> On Wed, Nov 21, 2007 at 10:59:41PM -0200, André Goddard Rosa wrote:
>> --- a/fast-import.c
>> +++ b/fast-import.c
>> @@ -2304,11 +2304,13 @@ int main(int argc, const char **argv)
>> else if (!prefixcmp(a, "--export-marks="))
>> mark_file = a + 15;
>> else if (!prefixcmp(a, "--export-pack-edges=")) {
>> + char *filename = a + 20;
>> +
>> if (pack_edges)
>> fclose(pack_edges);
>> - pack_edges = fopen(a + 20, "a");
>> + pack_edges = fopen(filename, "a");
>> if (!pack_edges)
>> - die("Cannot open %s: %s", a + 20, strerror(errno));
>> + die("Cannot open %s: %s", filename, strerror(errno));
>> } else if (!strcmp(a, "--force"))
>> force_update = 1;
>> else if (!strcmp(a, "--quiet"))
>
> Normally, the compiler takes care of such optimizations. It actually
> takes care of it much better than you can do yourself, and doing it
> yourself can even sometimes generate less optimized code because it
> gets in the compiler optimizations'way.
True, but I think another point of the patch is to address the
risk of two instances of "+ 20" going out of sync if/when the
option parsing is updated.
Not that I think André meant the patch as defensive coding (the
subject suggests it was meant to be a micro-optimization), nor
this is the good way to address that risk factor (parse-options
may be a better match for it).
next prev parent reply other threads:[~2007-11-22 20:21 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-22 0:59 [PATCH] Avoid recalculating filename string pointer André Goddard Rosa
2007-11-22 19:54 ` Mike Hommey
2007-11-22 20:21 ` Junio C Hamano [this message]
2007-11-25 21:43 ` [Resend PATCH] " André Goddard Rosa
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=7voddm3ubz.fsf@gitster.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=andre.goddard@gmail.com \
--cc=git@vger.kernel.org \
--cc=mh@glandium.org \
/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).