ref_transaction_commit(): simplify code using temporary variables

Use temporary variables in the for-loop blocks to simplify expressions in the rest of the loop. 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 cb198d21d3848f0c5f3d85a471a6a6793e540ca4
1 file changed +13 -8
refs.c
+13 -8
@@ -3435,10 +3435,12 @@ int ref_transaction_commit(struct ref_transaction *transaction,
3435
3436 /* Acquire all locks while verifying old values */
3437 for (i = 0; i < n; i++) {
3438 - locks[i] = update_ref_lock(updates[i]->refname,
3439 - (updates[i]->have_old ?
3440 - updates[i]->old_sha1 : NULL),
3441 - updates[i]->flags,
3438 + struct ref_update *update = updates[i];
3439 +
3440 + locks[i] = update_ref_lock(update->refname,
3441 + (update->have_old ?
3442 + update->old_sha1 : NULL),
3443 + update->flags,
3444 &types[i], onerr);
3445 if (!locks[i]) {
3446 ret = 1;
@@ -3447,16 +3449,19 @@ int ref_transaction_commit(struct ref_transaction *transaction,
3449 }
3450
3451 /* Perform updates first so live commits remain referenced */
3450 - for (i = 0; i < n; i++)
3451 - if (!is_null_sha1(updates[i]->new_sha1)) {
3452 + for (i = 0; i < n; i++) {
3453 + struct ref_update *update = updates[i];
3454 +
3455 + if (!is_null_sha1(update->new_sha1)) {
3456 ret = update_ref_write(msg,
3453 - updates[i]->refname,
3454 - updates[i]->new_sha1,
3457 + update->refname,
3458 + update->new_sha1,
3459 locks[i], onerr);
3460 locks[i] = NULL; /* freed by update_ref_write */
3461 if (ret)
3462 goto cleanup;
3463 }
3464 + }
3465
3466 /* Perform deletes now that updates are safely completed */
3467 for (i = 0; i < n; i++)