]> git.ipfire.org Git - thirdparty/git.git/commitdiff
commit: avoid parent list buildup in clear_commit_marks_many()
authorRené Scharfe <l.s.r@web.de>
Sun, 23 Feb 2025 08:26:04 +0000 (09:26 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 24 Feb 2025 16:51:18 +0000 (08:51 -0800)
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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
commit.c

index 540660359d4190f7dbc1aaa7668b033a6d16afe9..6efdb03997d9a0fd18e082f8500f4a8ca752ec6d 100644 (file)
--- 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)