提交 8a883b02 编写于 作者: J Jared Hance 提交者: Junio C Hamano

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: NJared Hance <jaredhance@gmail.com>
Signed-off-by: NJunio C Hamano <gitster@pobox.com>
上级 61bf126e
......@@ -22,13 +22,13 @@ static int progress;
static const char **refspec;
static int refspec_nr;
static int refspec_alloc;
static void add_refspec(const char *ref)
{
int nr = refspec_nr + 1;
refspec = xrealloc(refspec, nr * sizeof(char *));
refspec[nr-1] = ref;
refspec_nr = nr;
refspec_nr++;
ALLOC_GROW(refspec, refspec_nr, refspec_alloc);
refspec[refspec_nr-1] = ref;
}
static void set_refspecs(const char **refs, int nr)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册