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

[PATCH] Speed up commands that use rev-list when max-count is specified.

From
BMBenjamin C Meyer <bmeyer@rim.com>
Date
Mar 21, 2010, 03:31 UTC
Message-ID
<1269142267-17127-1-git-send-email-bmeyer@rim.com>
Many command have code similar to the following:
while ((commit = get_revision(rev)) != NULL) { ... }

This results in and extra call to get_revision that first finds the next revision and then notices max-count is 0 and returns NULL. Adding a max-count check before any expensive work reduces the runtime of all of the commands the have this pattern.

Depending on the use case this can have a big impact on the running time.
Signed-off-by: Benjamin C Meyer <bmeyer@rim.com>
---
 revision.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/revision.c b/revision.c
index 490b484..4673d70 100644
--- a/revision.c
+++ b/revision.c
@@ -2058,6 +2058,9 @@ static struct commit *get_revision_internal(struct rev_info *revs)
 
 struct commit *get_revision(struct rev_info *revs)
 {
+	if (revs->max_count == 0)
+		return NULL;
+
 	struct commit *c;
 	struct commit_list *reversed;
 
-- 
1.7.0.2
Next: Sverre Rabbelier
Message 1 of 4 in “Speed up commands that use rev-list when max-count is specified.”
  1. Speed up commands that use rev-list when max-count is specified.Benjamin C Meyer, Mar 21, 2010
  2. Sverre RabbelierMar 21, 2010
  3. Benjamin MeyerMar 21, 2010
  4. Mark LodatoMar 21, 2010

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.