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

[PATCH resend] commit: avoid parent list buildup in clear_commit_marks_many()

From
René Scharfe <l.s.r@web.de>
Date
Feb 23, 2025, 08:26 UTC
Message-ID
<2bd2d71f-0ee6-405f-bec8-368406ca53c8@web.de>
In-Reply-To
<16a7b572-0a3d-4707-9034-0dac69ea99ac@web.de>

clear_commit_marks_1() clears the marks of the first parent and its first parent and so on, and saves the higher numbered parents in a list for later. There is no benefit in keeping that list growing with each handled commit. Clear it after each run to reduce peak memory usage.

Signed-off-by: René Scharfe <l.s.r@web.de>
---
 commit.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/commit.c b/commit.c
index 540660359d..6efdb03997 100644
--- a/commit.c
+++ b/commit.c
@@ -780,14 +780,14 @@ static void clear_commit_marks_1(struct commit_list **plist,

 void clear_commit_marks_many(size_t nr, struct commit **commit, unsigned int mark)
 {
-	struct commit_list *list = NULL;
-
 	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++;
 	}
-	while (list)
-		clear_commit_marks_1(&list, pop_commit(&list), mark);
 }

 void clear_commit_marks(struct commit *commit, unsigned int mark)
--
2.48.1
Previous: René Scharfe
Message 6 of 6 in “commit: avoid parent list buildup in clear_commit_marks_many()”
  1. commit: avoid parent list buildup in clear_commit_marks_many()René Scharfe, Feb 9, 2025
  2. Patrick SteinhardtFeb 12, 2025
  3. René ScharfeFeb 13, 2025
  4. Patrick SteinhardtFeb 17, 2025
  5. René ScharfeFeb 23, 2025
  6. commit: avoid parent list buildup in clear_commit_marks_many()René Scharfe, Feb 23, 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.