git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Rast <trast@student.ethz.ch>
To: Jared Hance <jaredhance@gmail.com>
Cc: <git@vger.kernel.org>, <gitster@pobox.com>
Subject: Re: [PATCH] Remove useless temporary integer in builtin/push.c
Date: Fri, 30 Jul 2010 00:21:33 +0200	[thread overview]
Message-ID: <201007300021.34061.trast@student.ethz.ch> (raw)
In-Reply-To: <70ee84752cb7db08c65c608a12ed321dd2c26830.1280419073.git.jaredhance@gmail.com>

Jared Hance wrote:
> Creating a variable nr here to use throughout the function only to change
> refspec_nr to nr at the end, having not used refspec_nr the entire time,
> is rather pointless. Instead, simply increment refspec_nr.
> 
> Signed-off-by: Jared Hance <jaredhance@gmail.com>
[...]
> -	int nr = refspec_nr + 1;
> -	refspec = xrealloc(refspec, nr * sizeof(char *));
> -	refspec[nr-1] = ref;
> -	refspec_nr = nr;
> +	refspec_nr++;
> +	refspec = xrealloc(refspec, refspec_nr * sizeof(char *));
> +	refspec[refspec_nr-1] = ref;

While you're already here, you could switch to ALLOC_GROW instead to
avoid the n**2 behaviour of xrealloc...

-- 
Thomas Rast
trast@{inf,student}.ethz.ch

  reply	other threads:[~2010-07-29 22:21 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-29 15:59 [PATCH] Remove useless temporary integer in builtin/push.c Jared Hance
2010-07-29 22:21 ` Thomas Rast [this message]
2010-07-31 12:54   ` [PATCH 0/2] Clean up add_refspec " Jared Hance
2010-07-31 12:54     ` [PATCH 1/2] Remove useless temporary integer " Jared Hance
2010-08-02 18:51       ` Junio C Hamano
2010-07-31 12:57     ` [PATCH 2/2] Use ALLOC_GROW " Jared Hance

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=201007300021.34061.trast@student.ethz.ch \
    --to=trast@student.ethz.ch \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jaredhance@gmail.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).