git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Björn Steinbrink" <B.Steinbrink@gmx.de>
To: Thomas Spura <tomspur@fedoraproject.org>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] speed: reuse char instead of recreation in loop
Date: Mon, 25 May 2009 22:16:02 +0200	[thread overview]
Message-ID: <20090525201602.GA18471@atjola.homenet> (raw)
In-Reply-To: <pan.2009.05.25.19.44.10@fedoraproject.org>

On 2009.05.25 19:44:10 +0000, Thomas Spura wrote:
> Move a char and a char * outside of a for loop for speed improvements
> 
> Signed-off-by: Thomas Spura <tomspur@fedoraproject.org>
> ---
> Comments?
> 
>  transport.c |    7 +++----
>  1 files changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/transport.c b/transport.c
> index 17891d5..e350937 100644
> --- a/transport.c
> +++ b/transport.c
> @@ -263,11 +263,10 @@ static int write_refs_to_temp_dir(struct strbuf 
> *temp_dir,
>  		int refspec_nr, const char **refspec)
>  {
>  	int i;
> +	unsigned char sha1[20];
> +	char *ref;
>  
>  	for (i = 0; i < refspec_nr; i++) {
> -		unsigned char sha1[20];
> -		char *ref;
> -

I doubt that this makes any difference at all.

>  		if (dwim_ref(refspec[i], strlen(refspec[i]), sha1, &ref) !
> = 1)
>  			return error("Could not get ref %s", refspec[i]);
>  
> @@ -275,8 +274,8 @@ static int write_refs_to_temp_dir(struct strbuf 
> *temp_dir,
>  			free(ref);
>  			return -1;
>  		}
> -		free(ref);
>  	}
> +	free(ref);

And this now leaks memory.

Björn

  reply	other threads:[~2009-05-25 20:16 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-25 19:44 [PATCH] speed: reuse char instead of recreation in loop Thomas Spura
2009-05-25 20:16 ` Björn Steinbrink [this message]
2009-05-25 20:40   ` Thomas Spura
2009-05-25 22:08     ` Daniel Barkalow
2009-05-26 11:54       ` Stephen R. van den Berg
2009-05-25 20:39 ` René Scharfe
2009-05-25 20:44   ` Thomas Spura

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=20090525201602.GA18471@atjola.homenet \
    --to=b.steinbrink@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=tomspur@fedoraproject.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).