commit: skip already cleared parents in clear_commit_marks_1()

Don't put clean parents on the pending list, as they and their ancestors don't need any treatment and would be skipped later anyway. This saves the allocation and release of a commit list item in ca. 20% of the cases during a run of the test suite. Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

René Scharfe committed Dec 13, 2022 at 07:27 UTC 4cb39fcf19b969cdfa042b65d4d0b62a7fd0ba1e
1 file changed +4 -2
commit.c
+4 -2
@@ -693,8 +693,10 @@ static void clear_commit_marks_1(struct commit_list **plist,
693 if (!parents)
694 return;
695
696 - while ((parents = parents->next))
697 - commit_list_insert(parents->item, plist);
696 + while ((parents = parents->next)) {
697 + if (parents->item->object.flags & mark)
698 + commit_list_insert(parents->item, plist);
699 + }
700
701 commit = commit->parents->item;
702 }