tweak add_node_to_iter_list for clarity; no functional change
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
diff --git a/lib/commit_graph.c b/lib/commit_graph.c
index 9f0c3c9..2fca28a 100644
--- a/lib/commit_graph.c
+++ b/lib/commit_graph.c
@@ -152,17 +152,10 @@ add_node_to_iter_list(struct got_commit_graph *graph,
return;
}
- /*
- * If a child node is known, begin looping over the list there
- * instead of beginning from the list head. Parent commits are
- * traversed before their children.
- */
- n = child_node ? child_node : TAILQ_FIRST(&graph->iter_list);
-
/* Ensure that an iteration in progress will see this new commit. */
if (graph->iter_node) {
n = graph->iter_node;
- do {
+ while (n) {
next = TAILQ_NEXT(n, entry);
if (next &&
node->commit_timestamp >= next->commit_timestamp) {
@@ -170,13 +163,19 @@ add_node_to_iter_list(struct got_commit_graph *graph,
return;
}
n = next;
- } while (next);
-
+ }
TAILQ_INSERT_AFTER(&graph->iter_list, graph->iter_node,
node, entry);
return;
}
+ /*
+ * If a child node is known, begin looping over the list there
+ * instead of beginning from the list head. Parent commits are
+ * traversed before their children.
+ */
+ n = child_node ? child_node : TAILQ_FIRST(&graph->iter_list);
+
/* Insert into list based on committer timestamp. */
do {
if (node->commit_timestamp == n->commit_timestamp) {