Skip to content

Commit

Permalink
ref_transaction_commit(): work with transaction->updates in place
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Michael Haggerty authored and Junio C Hamano committed Apr 7, 2014
1 parent 84178db commit 6a40233
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions refs.c
Original file line number Diff line number Diff line change
Expand Up @@ -3413,19 +3413,17 @@ int ref_transaction_commit(struct ref_transaction *transaction,
const char *msg, enum action_on_err onerr)
{
int ret = 0, delnum = 0, i;
struct ref_update **updates;
const char **delnames;
int n = transaction->nr;
struct ref_update **updates = transaction->updates;

if (!n)
return 0;

/* Allocate work space */
updates = xmalloc(sizeof(*updates) * n);
delnames = xmalloc(sizeof(*delnames) * n);

/* Copy, sort, and reject duplicate refs */
memcpy(updates, transaction->updates, sizeof(*updates) * n);
qsort(updates, n, sizeof(*updates), ref_update_compare);
ret = ref_update_reject_duplicates(updates, n, onerr);
if (ret)
Expand Down Expand Up @@ -3480,7 +3478,6 @@ int ref_transaction_commit(struct ref_transaction *transaction,
for (i = 0; i < n; i++)
if (updates[i]->lock)
unlock_ref(updates[i]->lock);
free(updates);
free(delnames);
ref_transaction_free(transaction);
return ret;
Expand Down

0 comments on commit 6a40233

Please sign in to comment.