Use temporary variables in the for-loop blocks to simplify expressions
in the rest of the loop.

Signed-off-by: Michael Haggerty <mhag...@alum.mit.edu>
---
 refs.c | 25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/refs.c b/refs.c
index 335d0e2..ec638e9 100644
--- a/refs.c
+++ b/refs.c
@@ -3424,10 +3424,12 @@ int commit_ref_transaction(struct ref_transaction 
*transaction,
 
        /* Acquire all locks while verifying old values */
        for (i = 0; i < n; i++) {
-               locks[i] = update_ref_lock(updates[i]->refname,
-                                          (updates[i]->have_old ?
-                                           updates[i]->old_sha1 : NULL),
-                                          updates[i]->flags,
+               struct ref_update *update = updates[i];
+
+               locks[i] = update_ref_lock(update->refname,
+                                          (update->have_old ?
+                                           update->old_sha1 : NULL),
+                                          update->flags,
                                           &types[i], onerr);
                if (!locks[i]) {
                        ret = 1;
@@ -3436,23 +3438,28 @@ int commit_ref_transaction(struct ref_transaction 
*transaction,
        }
 
        /* Perform updates first so live commits remain referenced */
-       for (i = 0; i < n; i++)
-               if (!is_null_sha1(updates[i]->new_sha1)) {
+       for (i = 0; i < n; i++) {
+               struct ref_update *update = updates[i];
+
+               if (!is_null_sha1(update->new_sha1)) {
                        ret = update_ref_write(msg,
-                                              updates[i]->refname,
-                                              updates[i]->new_sha1,
+                                              update->refname,
+                                              update->new_sha1,
                                               locks[i], onerr);
                        locks[i] = NULL; /* freed by update_ref_write */
                        if (ret)
                                goto cleanup;
                }
+       }
 
        /* Perform deletes now that updates are safely completed */
-       for (i = 0; i < n; i++)
+       for (i = 0; i < n; i++) {
                if (locks[i]) {
                        delnames[delnum++] = locks[i]->ref_name;
                        ret |= delete_ref_loose(locks[i], types[i]);
                }
+       }
+
        ret |= repack_without_refs(delnames, delnum);
        for (i = 0; i < delnum; i++)
                unlink_or_warn(git_path("logs/%s", delnames[i]));
-- 
1.9.0

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to