git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Benjamin C Meyer <bmeyer@rim.com>
To: git@vger.kernel.org
Cc: Benjamin C Meyer <bmeyer@rim.com>
Subject: [PATCH] Speed up commands that use rev-list when max-count is specified.
Date: Sat, 20 Mar 2010 23:31:07 -0400	[thread overview]
Message-ID: <1269142267-17127-1-git-send-email-bmeyer@rim.com> (raw)

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

             reply	other threads:[~2010-03-21  3:31 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-21  3:31 Benjamin C Meyer [this message]
2010-03-21 11:12 ` [PATCH] Speed up commands that use rev-list when max-count is specified Sverre Rabbelier
2010-03-21 16:57   ` Benjamin Meyer
2010-03-21 14:09 ` Mark Lodato

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=1269142267-17127-1-git-send-email-bmeyer@rim.com \
    --to=bmeyer@rim.com \
    --cc=git@vger.kernel.org \
    /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).