From: Karthik Nayak Date: Sat, 06 Jun 2015 07:09:33 GMT Subject: [WIP/PATCH v5 02/10] for-each-ref: clean up code Message-ID: <1433574581-23980-2-git-send-email-karthik.188@gmail.com> In-Reply-To: <1433574581-23980-1-git-send-email-karthik.188@gmail.com> In 'grab_single_ref()' remove the extra count variable 'cnt' and use the variable 'grab_cnt' of structure 'grab_ref_cbdata' directly instead. Change comment in 'struct ref_sort' to reflect changes in code. Mentored-by: Christian Couder Mentored-by: Matthieu Moy Signed-off-by: Karthik Nayak --- builtin/for-each-ref.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/builtin/for-each-ref.c b/builtin/for-each-ref.c index 48da5a4..0ca9836 100644 --- a/builtin/for-each-ref.c +++ b/builtin/for-each-ref.c @@ -27,7 +27,7 @@ struct atom_value { struct ref_sort { struct ref_sort *next; - int atom; /* index into used_atom array */ + int atom; /* index into 'struct atom_value *' array */ unsigned reverse : 1; }; @@ -881,7 +881,6 @@ static int grab_single_ref(const char *refname, const unsigned char *sha1, int f { 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); @@ -898,10 +897,8 @@ static int grab_single_ref(const char *refname, const unsigned char *sha1, int f */ ref = new_refinfo(refname, sha1, 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; } -- 2.4.2