@matheusbsbs / matheus-bagliano / commits / 8a883b0260
Fork 0

builtin/push.c: remove useless temporary variable

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. While at it, use ALLOC_GROW() instead of xrealloc(). Signed-off-by: Jared Hance <jaredhance@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jared Hance committed Jul 31, 2010 at 08:54 UTC 8a883b0260ba7f8d6e4c025ae3c32b454e80ade5
1 file changed +4 -4
builtin/push.c
+4 -4
@@ -22,13 +22,13 @@ static int progress;
22
23 static const char **refspec;
24 static int refspec_nr;
25 +static int refspec_alloc;
26
27 static void add_refspec(const char *ref)
28 {
28 - int nr = refspec_nr + 1;
29 - refspec = xrealloc(refspec, nr * sizeof(char *));
30 - refspec[nr-1] = ref;
31 - refspec_nr = nr;
29 + refspec_nr++;
30 + ALLOC_GROW(refspec, refspec_nr, refspec_alloc);
31 + refspec[refspec_nr-1] = ref;
32 }
33
34 static void set_refspecs(const char **refs, int nr)