ref_transaction_commit(): work with transaction->updates in place
Now that we free the transaction when we are done, there is no need to make a copy of transaction->updates before working with it. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
84178db76f
commit
6a402338ec
5
refs.c
5
refs.c
@ -3413,19 +3413,17 @@ int ref_transaction_commit(struct ref_transaction *transaction,
|
|||||||
const char *msg, enum action_on_err onerr)
|
const char *msg, enum action_on_err onerr)
|
||||||
{
|
{
|
||||||
int ret = 0, delnum = 0, i;
|
int ret = 0, delnum = 0, i;
|
||||||
struct ref_update **updates;
|
|
||||||
const char **delnames;
|
const char **delnames;
|
||||||
int n = transaction->nr;
|
int n = transaction->nr;
|
||||||
|
struct ref_update **updates = transaction->updates;
|
||||||
|
|
||||||
if (!n)
|
if (!n)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* Allocate work space */
|
/* Allocate work space */
|
||||||
updates = xmalloc(sizeof(*updates) * n);
|
|
||||||
delnames = xmalloc(sizeof(*delnames) * n);
|
delnames = xmalloc(sizeof(*delnames) * n);
|
||||||
|
|
||||||
/* Copy, sort, and reject duplicate refs */
|
/* Copy, sort, and reject duplicate refs */
|
||||||
memcpy(updates, transaction->updates, sizeof(*updates) * n);
|
|
||||||
qsort(updates, n, sizeof(*updates), ref_update_compare);
|
qsort(updates, n, sizeof(*updates), ref_update_compare);
|
||||||
ret = ref_update_reject_duplicates(updates, n, onerr);
|
ret = ref_update_reject_duplicates(updates, n, onerr);
|
||||||
if (ret)
|
if (ret)
|
||||||
@ -3480,7 +3478,6 @@ cleanup:
|
|||||||
for (i = 0; i < n; i++)
|
for (i = 0; i < n; i++)
|
||||||
if (updates[i]->lock)
|
if (updates[i]->lock)
|
||||||
unlock_ref(updates[i]->lock);
|
unlock_ref(updates[i]->lock);
|
||||||
free(updates);
|
|
||||||
free(delnames);
|
free(delnames);
|
||||||
ref_transaction_free(transaction);
|
ref_transaction_free(transaction);
|
||||||
return ret;
|
return ret;
|
||||||
|
Reference in New Issue
Block a user