bisect: make skipped array functions more generic
So they can be used on the good array too. This is done by renaming many functions and some variables to remove "skip" in the name, and by adding a "struct sha1_array *array" argument where needed. While at it, make the second argument to "lookup_sha1_array" const. It becomes "const unsigned char *sha1". Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Christian Couder committed
May 9, 2009 at 17:55 UTC
aaaff9e2d29a68c23a416bcc5f3f382504770bf8
1 file changed
+12
-12
bisect.c
+12
-12
@@ -479,27 +479,26 @@ void read_bisect_paths(struct argv_array *array)
479
fclose(fp);
480
}
481
482
-static int skipcmp(const void *a, const void *b)
482
+static int array_cmp(const void *a, const void *b)
483
{
484
return hashcmp(a, b);
485
}
486
487
-static void prepare_skipped(void)
487
+static void sort_sha1_array(struct sha1_array *array)
488
{
489
- qsort(skipped_revs.sha1, skipped_revs.sha1_nr,
490
- sizeof(*skipped_revs.sha1), skipcmp);
489
+ qsort(array->sha1, array->sha1_nr, sizeof(*array->sha1), array_cmp);
490
}
491
493
-static const unsigned char *skipped_sha1_access(size_t index, void *table)
492
+static const unsigned char *sha1_access(size_t index, void *table)
493
{
495
- unsigned char (*skipped)[20] = table;
496
- return skipped[index];
494
+ unsigned char (*array)[20] = table;
495
+ return array[index];
496
}
497
499
-static int lookup_skipped(unsigned char *sha1)
498
+static int lookup_sha1_array(struct sha1_array *array,
499
+ const unsigned char *sha1)
500
{
501
- return sha1_pos(sha1, skipped_revs.sha1, skipped_revs.sha1_nr,
502
- skipped_sha1_access);
501
+ return sha1_pos(sha1, array->sha1, array->sha1_nr, sha1_access);
502
}
503
504
struct commit_list *filter_skipped(struct commit_list *list,
@@ -513,12 +512,13 @@ struct commit_list *filter_skipped(struct commit_list *list,
512
if (!skipped_revs.sha1_nr)
513
return list;
514
516
- prepare_skipped();
515
+ sort_sha1_array(&skipped_revs);
516
517
while (list) {
518
struct commit_list *next = list->next;
519
list->next = NULL;
521
- if (0 <= lookup_skipped(list->item->object.sha1)) {
520
+ if (0 <= lookup_sha1_array(&skipped_revs,
521
+ list->item->object.sha1)) {
522
/* Move current to tried list */
523
*tried = list;
524
tried = &list->next;