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>
Michael Haggerty committed
Apr 7, 2014 at 15:48 UTC
6a402338ec9ca0369e1801533dda2108689ceaaf
1 file changed
+1
-4
refs.c
+1
-4
@@ -3413,19 +3413,17 @@ int ref_transaction_commit(struct ref_transaction *transaction,
3413
const char *msg, enum action_on_err onerr)
3414
{
3415
int ret = 0, delnum = 0, i;
3416
- struct ref_update **updates;
3416
const char **delnames;
3417
int n = transaction->nr;
3418
+ struct ref_update **updates = transaction->updates;
3419
3420
if (!n)
3421
return 0;
3422
3423
/* Allocate work space */
3424
- updates = xmalloc(sizeof(*updates) * n);
3424
delnames = xmalloc(sizeof(*delnames) * n);
3425
3426
/* Copy, sort, and reject duplicate refs */
3428
- memcpy(updates, transaction->updates, sizeof(*updates) * n);
3427
qsort(updates, n, sizeof(*updates), ref_update_compare);
3428
ret = ref_update_reject_duplicates(updates, n, onerr);
3429
if (ret)
@@ -3480,7 +3478,6 @@ cleanup:
3478
for (i = 0; i < n; i++)
3479
if (updates[i]->lock)
3480
unlock_ref(updates[i]->lock);
3483
- free(updates);
3481
free(delnames);
3482
ref_transaction_free(transaction);
3483
return ret;