git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/3] revision: append to list instead of insert and reverse

From
René Scharfe <rene.scharfe@lsrfire.ath.cx>
Date
Apr 25, 2012, 20:35 UTC
Message-ID
<4F98601D.3070303@lsrfire.ath.cx>
In-Reply-To
<4F985D0A.9020100@lsrfire.ath.cx>

By using commit_list_insert(), we added new items to the top of the list and, since this is not the order we want, reversed it afterwards. Simplify this process by adding new items at the bottom instead, getting rid of the reversal step.

Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
---
 revision.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/revision.c b/revision.c
index edb225d..9e63baa 100644
--- a/revision.c
+++ b/revision.c
@@ -2071,6 +2071,7 @@ int prepare_revision_walk(struct rev_info *revs)
 {
 	int nr = revs->pending.nr;
 	struct object_array_entry *e, *list;
+	struct commit_list **next = &revs->commits;
 
 	e = list = revs->pending.objects;
 	revs->pending.nr = 0;
@@ -2081,12 +2082,11 @@ int prepare_revision_walk(struct rev_info *revs)
 		if (commit) {
 			if (!(commit->object.flags & SEEN)) {
 				commit->object.flags |= SEEN;
-				commit_list_insert(commit, &revs->commits);
+				next = commit_list_append(commit, next);
 			}
 		}
 		e++;
 	}
-	commit_list_reverse(&revs->commits);
 	commit_list_sort_by_date(&revs->commits);
 	if (!revs->leak_pending)
 		free(list);
-- 
1.7.10
Previous: René ScharfeNext: René Scharfe
Message 7 of 8 in “Possible segfault introduced in commit.c”
  1. Michael MuellerApr 25, 2012
  2. Jeff KingApr 25, 2012
  3. René ScharfeApr 25, 2012
  4. 1/3 sequencer: export commit_list_append()René Scharfe, Apr 25, 2012
  5. Junio C HamanoApr 25, 2012
  6. René ScharfeApr 30, 2012
  7. 2/3 revision: append to list instead of insert and reverseRené Scharfe, Apr 25, 2012
  8. 3/3 commit: remove commit_list_reverse()René Scharfe, Apr 25, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.