commit: avoid parent list buildup in clear_commit_marks_many()
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>
René Scharfe committed
Feb 23, 2025 at 09:26 UTC
1ca727f230d83db20952f8ae7ce2f1749d744334
1 file changed
+4
-4
commit.c
+4
-4
@@ -780,14 +780,14 @@ static void clear_commit_marks_1(struct commit_list **plist,
780
781
void clear_commit_marks_many(size_t nr, struct commit **commit, unsigned int mark)
782
{
783
- struct commit_list *list = NULL;
784
-
783
for (size_t i = 0; i < nr; i++) {
784
+ struct commit_list *list = NULL;
785
+
786
clear_commit_marks_1(&list, *commit, mark);
787
+ while (list)
788
+ clear_commit_marks_1(&list, pop_commit(&list), mark);
789
commit++;
790
}
789
- while (list)
790
- clear_commit_marks_1(&list, pop_commit(&list), mark);
791
}
792
793
void clear_commit_marks(struct commit *commit, unsigned int mark)