Skip to content

Commit aaaff9e

Browse files
chriscoolgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2b02069 commit aaaff9e

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

bisect.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -479,27 +479,26 @@ void read_bisect_paths(struct argv_array *array)
479479
fclose(fp);
480480
}
481481

482-
static int skipcmp(const void *a, const void *b)
482+
static int array_cmp(const void *a, const void *b)
483483
{
484484
return hashcmp(a, b);
485485
}
486486

487-
static void prepare_skipped(void)
487+
static void sort_sha1_array(struct sha1_array *array)
488488
{
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);
491490
}
492491

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)
494493
{
495-
unsigned char (*skipped)[20] = table;
496-
return skipped[index];
494+
unsigned char (*array)[20] = table;
495+
return array[index];
497496
}
498497

499-
static int lookup_skipped(unsigned char *sha1)
498+
static int lookup_sha1_array(struct sha1_array *array,
499+
const unsigned char *sha1)
500500
{
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);
503502
}
504503

505504
struct commit_list *filter_skipped(struct commit_list *list,
@@ -513,12 +512,13 @@ struct commit_list *filter_skipped(struct commit_list *list,
513512
if (!skipped_revs.sha1_nr)
514513
return list;
515514

516-
prepare_skipped();
515+
sort_sha1_array(&skipped_revs);
517516

518517
while (list) {
519518
struct commit_list *next = list->next;
520519
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)) {
522522
/* Move current to tried list */
523523
*tried = list;
524524
tried = &list->next;

0 commit comments

Comments
 (0)