git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] commit: move clear_commit_marks_many() loop body to clear_commit_marks()

From
René Scharfe <l.s.r@web.de>
Date
Mar 23, 2025, 09:53 UTC
Message-ID
<80bfd7a9-904c-49d8-a367-ca268c096a9f@web.de>

clear_commit_marks_many() clears multiple commits one by one. Move the code for handling a single commit to clear_commit_marks() and call it instead of the other way around, to simplify the code.

Signed-off-by: René Scharfe <l.s.r@web.de>
---
 commit.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/commit.c b/commit.c
index 6efdb03997..425503bb9f 100644
--- a/commit.c
+++ b/commit.c
@@ -780,19 +780,17 @@ static void clear_commit_marks_1(struct commit_list **plist,

 void clear_commit_marks_many(size_t nr, struct commit **commit, unsigned int mark)
 {
-	for (size_t i = 0; i < nr; i++) {
-		struct commit_list *list = NULL;
-
-		clear_commit_marks_1(&list, *commit, mark);
-		while (list)
-			clear_commit_marks_1(&list, pop_commit(&list), mark);
-		commit++;
-	}
+	for (size_t i = 0; i < nr; i++)
+		clear_commit_marks(commit[i], mark);
 }

 void clear_commit_marks(struct commit *commit, unsigned int mark)
 {
-	clear_commit_marks_many(1, &commit, mark);
+	struct commit_list *list = NULL;
+
+	clear_commit_marks_1(&list, commit, mark);
+	while (list)
+		clear_commit_marks_1(&list, pop_commit(&list), mark);
 }

 struct commit *pop_commit(struct commit_list **stack)
--
2.49.0
Next: Junio C Hamano
Message 1 of 2 in “commit: move clear_commit_marks_many() loop body to clear_commit_marks()”
  1. commit: move clear_commit_marks_many() loop body to clear_commit_marks()René Scharfe, Mar 23, 2025
  2. Junio C HamanoMar 24, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.