git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christian Couder <chriscool@tuxfamily.org>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, Johannes Schindelin <Johannes.Schindelin@gmx.de>
Subject: [PATCH 3/4] bisect: use the new generic "sha1_pos" function to lookup sha1
Date: Sat, 4 Apr 2009 22:59:36 +0200	[thread overview]
Message-ID: <20090404225936.cdcad81b.chriscool@tuxfamily.org> (raw)

instead of the specific one that was simpler but less efficient.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
 bisect.c |   23 +++++++++--------------
 1 files changed, 9 insertions(+), 14 deletions(-)

diff --git a/bisect.c b/bisect.c
index affba41..336d611 100644
--- a/bisect.c
+++ b/bisect.c
@@ -5,6 +5,7 @@
 #include "refs.h"
 #include "list-objects.h"
 #include "quote.h"
+#include "sha1-lookup.h"
 #include "bisect.h"
 
 
@@ -461,22 +462,16 @@ static void prepare_skipped(void)
 	qsort(skipped_sha1, skipped_sha1_nr, sizeof(*skipped_sha1), skipcmp);
 }
 
+static const unsigned char *skipped_sha1_access(size_t index, void *table)
+{
+	unsigned char (*skipped)[20] = table;
+	return skipped[index];
+}
+
 static int lookup_skipped(unsigned char *sha1)
 {
-	int lo, hi;
-	lo = 0;
-	hi = skipped_sha1_nr;
-	while (lo < hi) {
-		int mi = (lo + hi) / 2;
-		int cmp = hashcmp(sha1, skipped_sha1[mi]);
-		if (!cmp)
-			return mi;
-		if (cmp < 0)
-			hi = mi;
-		else
-			lo = mi + 1;
-	}
-	return -lo - 1;
+	return sha1_pos(sha1, skipped_sha1, skipped_sha1_nr,
+			skipped_sha1_access);
 }
 
 struct commit_list *filter_skipped(struct commit_list *list,
-- 
1.6.2.2.404.ge96f3.dirty

                 reply	other threads:[~2009-04-04 21:02 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20090404225936.cdcad81b.chriscool@tuxfamily.org \
    --to=chriscool@tuxfamily.org \
    --cc=Johannes.Schindelin@gmx.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).