bisect: use the new generic "sha1_pos" function to lookup sha1
instead of the specific one that was simpler but less efficient. Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Christian Couder committed
Apr 4, 2009 at 22:59 UTC
4eb5b64631d281f3789b052efac53f4c1ec2c1b6
1 file changed
+9
-14
bisect.c
+9
-14
@@ -2,6 +2,7 @@
2
#include "commit.h"
3
#include "diff.h"
4
#include "revision.h"
5
+#include "sha1-lookup.h"
6
#include "bisect.h"
7
8
static unsigned char (*skipped_sha1)[20];
@@ -399,22 +400,16 @@ static void prepare_skipped(void)
400
qsort(skipped_sha1, skipped_sha1_nr, sizeof(*skipped_sha1), skipcmp);
401
}
402
403
+static const unsigned char *skipped_sha1_access(size_t index, void *table)
404
+{
405
+ unsigned char (*skipped)[20] = table;
406
+ return skipped[index];
407
+}
408
+
409
static int lookup_skipped(unsigned char *sha1)
410
{
404
- int lo, hi;
405
- lo = 0;
406
- hi = skipped_sha1_nr;
407
- while (lo < hi) {
408
- int mi = (lo + hi) / 2;
409
- int cmp = hashcmp(sha1, skipped_sha1[mi]);
410
- if (!cmp)
411
- return mi;
412
- if (cmp < 0)
413
- hi = mi;
414
- else
415
- lo = mi + 1;
416
- }
417
- return -lo - 1;
411
+ return sha1_pos(sha1, skipped_sha1, skipped_sha1_nr,
412
+ skipped_sha1_access);
413
}
414
415
struct commit_list *filter_skipped(struct commit_list *list,