From: Karthik Nayak Date: Sat, 13 Jun 2015 19:37:20 +0000 (+0530) Subject: for-each-ref: clean up code X-Git-Tag: v2.6.0-rc0~116^2~9 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=fc80edcae1cdaac42b2e09c64df2e5cd06e3a336;p=thirdparty%2Fgit.git for-each-ref: clean up code In 'grab_single_ref()' remove the extra count variable 'cnt' and use the variable 'grab_cnt' of structure 'grab_ref_cbdata' directly instead. Mentored-by: Christian Couder Mentored-by: Matthieu Moy Signed-off-by: Karthik Nayak Reviewed-by: Matthieu Moy Signed-off-by: Junio C Hamano --- diff --git a/builtin/for-each-ref.c b/builtin/for-each-ref.c index cc65620930..f0d7d448a6 100644 --- a/builtin/for-each-ref.c +++ b/builtin/for-each-ref.c @@ -897,7 +897,6 @@ static int grab_single_ref(const char *refname, const struct object_id *oid, { struct grab_ref_cbdata *cb = cb_data; struct refinfo *ref; - int cnt; if (flag & REF_BAD_NAME) { warning("ignoring ref with broken name %s", refname); @@ -914,10 +913,8 @@ static int grab_single_ref(const char *refname, const struct object_id *oid, */ ref = new_refinfo(refname, oid->hash, flag); - cnt = cb->grab_cnt; - REALLOC_ARRAY(cb->grab_array, cnt + 1); - cb->grab_array[cnt++] = ref; - cb->grab_cnt = cnt; + REALLOC_ARRAY(cb->grab_array, cb->grab_cnt + 1); + cb->grab_array[cb->grab_cnt++] = ref; return 0; }