diffcore-break: use a goto instead of a redundant if statement
The condition "if (q->nr <= j)" checks whether the loop exited normally or via a break statement. Avoid this check by replacing the jump out of the inner loop with a jump to the end of the outer loop, which makes it obvious that diff_q is not executed when the peer survives. Signed-off-by: Alex Henrie <alexhenrie24@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Alex Henrie committed
Sep 30, 2019 at 20:29 UTC
baed6bbb5b56a501d1137e53caba614f77c3435d
1 file changed
+6
-6
diffcore-break.c
+6
-6
@@ -286,17 +286,17 @@ void diffcore_merge_broken(void)
286
/* Peer survived. Merge them */
287
merge_broken(p, pp, &outq);
288
q->queue[j] = NULL;
289
- break;
289
+ goto next;
290
}
291
}
292
- if (q->nr <= j)
293
- /* The peer did not survive, so we keep
294
- * it in the output.
295
- */
296
- diff_q(&outq, p);
292
+ /* The peer did not survive, so we keep
293
+ * it in the output.
294
+ */
295
+ diff_q(&outq, p);
296
}
297
else
298
diff_q(&outq, p);
299
+next:;
300
}
301
free(q->queue);
302
*q = outq;