git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] commit: avoid parent list buildup in clear_commit_marks_many()
@ 2025-02-09 10:41 René Scharfe
  2025-02-12  7:05 ` Patrick Steinhardt
  2025-02-23  8:26 ` [PATCH resend] " René Scharfe
  0 siblings, 2 replies; 6+ messages in thread
From: René Scharfe @ 2025-02-09 10:41 UTC (permalink / raw)
  To: Git List

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

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-02-23  8:26 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-09 10:41 [PATCH] commit: avoid parent list buildup in clear_commit_marks_many() René Scharfe
2025-02-12  7:05 ` Patrick Steinhardt
2025-02-13 21:38   ` René Scharfe
2025-02-17  6:33     ` Patrick Steinhardt
2025-02-23  8:25       ` René Scharfe
2025-02-23  8:26 ` [PATCH resend] " René Scharfe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).