From: "René Scharfe" <l.s.r@web.de>
To: Git List <git@vger.kernel.org>
Cc: Junio C Hamano <gitster@pobox.com>
Subject: [PATCH resend] commit: avoid parent list buildup in clear_commit_marks_many()
Date: Sun, 23 Feb 2025 09:26:04 +0100 [thread overview]
Message-ID: <2bd2d71f-0ee6-405f-bec8-368406ca53c8@web.de> (raw)
In-Reply-To: <16a7b572-0a3d-4707-9034-0dac69ea99ac@web.de>
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
prev parent reply other threads:[~2025-02-23 8:26 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` René Scharfe [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2bd2d71f-0ee6-405f-bec8-368406ca53c8@web.de \
--to=l.s.r@web.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).