Re: [PATCH] Remove useless temporary integer in builtin/push.c
- From
Thomas Rast <trast@student.ethz.ch>
- Date
- Jul 29, 2010, 22:21 UTC
- Message-ID
- <201007300021.34061.trast@student.ethz.ch>
- In-Reply-To
- <70ee84752cb7db08c65c608a12ed321dd2c26830.1280419073.git.jaredhance@gmail.com>
Jared Hance wrote:
Show 5 quoted lines
> 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>
[...]
Show 7 quoted lines
> - 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