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

[PATCH] walker: avoid quadratic list insertion in mark_complete

From
René Scharfe <l.s.r@web.de>
Date
Aug 21, 2014, 18:30 UTC
Message-ID
<53F63AC0.1090605@web.de>

Similar to 16445242 (fetch-pack: avoid quadratic list insertion in mark_complete), sort only after all refs are collected instead of while inserting. The result is the same, but it's more efficient that way. The difference will only be measurable in repositories with a large number of refs.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
---
 walker.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/walker.c b/walker.c
index 0148264..0596e99 100644
--- a/walker.c
+++ b/walker.c
@@ -205,7 +205,7 @@ static int mark_complete(const char *path, const unsigned char *sha1, int flag,
 	struct commit *commit = lookup_commit_reference_gently(sha1, 1);
 	if (commit) {
 		commit->object.flags |= COMPLETE;
-		commit_list_insert_by_date(commit, &complete);
+		commit_list_insert(commit, &complete);
 	}
 	return 0;
 }
@@ -271,8 +271,10 @@ int walker_fetch(struct walker *walker, int targets, char **target,
 		}
 	}
 
-	if (!walker->get_recover)
+	if (!walker->get_recover) {
 		for_each_ref(mark_complete, NULL);
+		commit_list_sort_by_date(&complete);
+	}
 
 	for (i = 0; i < targets; i++) {
 		if (interpret_target(walker, target[i], &sha1[20 * i])) {
-- 
2.1.0
Next: Jeff King
Message 1 of 2 in “walker: avoid quadratic list insertion in mark_complete”
  1. walker: avoid quadratic list insertion in mark_completeRené Scharfe, Aug 21, 2014
  2. Jeff KingAug 22, 2014

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.