Skip to content

Commit 6a40233

Browse files
mhaggergitster
authored andcommitted
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>
1 parent 84178db commit 6a40233

1 file changed

Lines changed: 1 addition & 4 deletions

File tree

refs.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3413,19 +3413,17 @@ int ref_transaction_commit(struct ref_transaction *transaction,
34133413
const char *msg, enum action_on_err onerr)
34143414
{
34153415
int ret = 0, delnum = 0, i;
3416-
struct ref_update **updates;
34173416
const char **delnames;
34183417
int n = transaction->nr;
3418+
struct ref_update **updates = transaction->updates;
34193419

34203420
if (!n)
34213421
return 0;
34223422

34233423
/* Allocate work space */
3424-
updates = xmalloc(sizeof(*updates) * n);
34253424
delnames = xmalloc(sizeof(*delnames) * n);
34263425

34273426
/* Copy, sort, and reject duplicate refs */
3428-
memcpy(updates, transaction->updates, sizeof(*updates) * n);
34293427
qsort(updates, n, sizeof(*updates), ref_update_compare);
34303428
ret = ref_update_reject_duplicates(updates, n, onerr);
34313429
if (ret)
@@ -3480,7 +3478,6 @@ int ref_transaction_commit(struct ref_transaction *transaction,
34803478
for (i = 0; i < n; i++)
34813479
if (updates[i]->lock)
34823480
unlock_ref(updates[i]->lock);
3483-
free(updates);
34843481
free(delnames);
34853482
ref_transaction_free(transaction);
34863483
return ret;

0 commit comments

Comments
 (0)