提交 fc80edca 编写于 作者: K Karthik Nayak 提交者: Junio C Hamano

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: NChristian Couder <christian.couder@gmail.com>
Mentored-by: NMatthieu Moy <matthieu.moy@grenoble-inp.fr>
Signed-off-by: NKarthik Nayak <karthik.188@gmail.com>
Reviewed-by: NMatthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: NJunio C Hamano <gitster@pobox.com>
上级 ed01e206
......@@ -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;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册