Skip to content

Commit 1ca727f

Browse files
rscharfegitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2d2a71c commit 1ca727f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

commit.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -780,14 +780,14 @@ static void clear_commit_marks_1(struct commit_list **plist,
780780

781781
void clear_commit_marks_many(size_t nr, struct commit **commit, unsigned int mark)
782782
{
783-
struct commit_list *list = NULL;
784-
785783
for (size_t i = 0; i < nr; i++) {
784+
struct commit_list *list = NULL;
785+
786786
clear_commit_marks_1(&list, *commit, mark);
787+
while (list)
788+
clear_commit_marks_1(&list, pop_commit(&list), mark);
787789
commit++;
788790
}
789-
while (list)
790-
clear_commit_marks_1(&list, pop_commit(&list), mark);
791791
}
792792

793793
void clear_commit_marks(struct commit *commit, unsigned int mark)

0 commit comments

Comments
 (0)