summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Couder <chriscool@tuxfamily.org>2009-05-09 15:55:44 (GMT)
committerJunio C Hamano <gitster@pobox.com>2009-05-10 21:30:30 (GMT)
commit1da8c4fc2c85ed99e23d640bddedd8119150a1b8 (patch)
treeb0d86256c4f4868cf8da827e622fe00f9de3c639
parentaaaff9e2d29a68c23a416bcc5f3f382504770bf8 (diff)
downloadgit-1da8c4fc2c85ed99e23d640bddedd8119150a1b8.zip
git-1da8c4fc2c85ed99e23d640bddedd8119150a1b8.tar.gz
git-1da8c4fc2c85ed99e23d640bddedd8119150a1b8.tar.bz2
bisect: automatically sort sha1_array if needed when looking it up
This makes sha1_array easier to use, so later patches will be simpler. Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--bisect.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/bisect.c b/bisect.c
index 77edeca..d2a34d1 100644
--- a/bisect.c
+++ b/bisect.c
@@ -13,6 +13,7 @@ struct sha1_array {
unsigned char (*sha1)[20];
int sha1_nr;
int sha1_alloc;
+ int sorted;
};
static struct sha1_array good_revs;
@@ -487,6 +488,8 @@ static int array_cmp(const void *a, const void *b)
static void sort_sha1_array(struct sha1_array *array)
{
qsort(array->sha1, array->sha1_nr, sizeof(*array->sha1), array_cmp);
+
+ array->sorted = 1;
}
static const unsigned char *sha1_access(size_t index, void *table)
@@ -498,6 +501,9 @@ static const unsigned char *sha1_access(size_t index, void *table)
static int lookup_sha1_array(struct sha1_array *array,
const unsigned char *sha1)
{
+ if (!array->sorted)
+ sort_sha1_array(array);
+
return sha1_pos(sha1, array->sha1, array->sha1_nr, sha1_access);
}
@@ -512,8 +518,6 @@ struct commit_list *filter_skipped(struct commit_list *list,
if (!skipped_revs.sha1_nr)
return list;
- sort_sha1_array(&skipped_revs);
-
while (list) {
struct commit_list *next = list->next;
list->next = NULL;