ref_transaction_commit(): work with transaction->updates in place
authorMichael Haggerty <mhagger@alum.mit.edu>
Mon, 7 Apr 2014 13:48:18 +0000 (15:48 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 7 Apr 2014 19:09:16 +0000 (12:09 -0700)
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>
refs.c
diff --git a/refs.c b/refs.c
index c058f304deaa4617dd1dfa81e5ce67ef42b46bf6..728a76164830368637e95390d95ce3f7c7df659e 100644 (file)
--- a/refs.c
+++ b/refs.c
@@ -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)
@@ -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;