Skip to content

Commit fc80edc

Browse files
KarthikNayakgitster
authored andcommitted
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 <[email protected]> Mentored-by: Matthieu Moy <[email protected]> Signed-off-by: Karthik Nayak <[email protected]> Reviewed-by: Matthieu Moy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ed01e20 commit fc80edc

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

builtin/for-each-ref.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -897,7 +897,6 @@ static int grab_single_ref(const char *refname, const struct object_id *oid,
897897
{
898898
struct grab_ref_cbdata *cb = cb_data;
899899
struct refinfo *ref;
900-
int cnt;
901900

902901
if (flag & REF_BAD_NAME) {
903902
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,
914913
*/
915914
ref = new_refinfo(refname, oid->hash, flag);
916915

917-
cnt = cb->grab_cnt;
918-
REALLOC_ARRAY(cb->grab_array, cnt + 1);
919-
cb->grab_array[cnt++] = ref;
920-
cb->grab_cnt = cnt;
916+
REALLOC_ARRAY(cb->grab_array, cb->grab_cnt + 1);
917+
cb->grab_array[cb->grab_cnt++] = ref;
921918
return 0;
922919
}
923920

0 commit comments

Comments
 (0)