bisect.c: use commit-slab for commit weight instead of commit->util

It's done so that commit->util can be removed. See more explanation in
the commit that removes commit->util.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Nguyễn Thái Ngọc Duy 2018-05-19 07:28:25 +02:00 committed by Junio C Hamano
parent 87be252333
commit bb408ac95d

View File

@ -12,6 +12,7 @@
#include "bisect.h"
#include "sha1-array.h"
#include "argv-array.h"
#include "commit-slab.h"
static struct oid_array good_revs;
static struct oid_array skipped_revs;
@ -70,16 +71,19 @@ static void clear_distance(struct commit_list *list)
}
}
define_commit_slab(commit_weight, int *);
static struct commit_weight commit_weight;
#define DEBUG_BISECT 0
static inline int weight(struct commit_list *elem)
{
return *((int*)(elem->item->util));
return **commit_weight_at(&commit_weight, elem->item);
}
static inline void weight_set(struct commit_list *elem, int weight)
{
*((int*)(elem->item->util)) = weight;
**commit_weight_at(&commit_weight, elem->item) = weight;
}
static int count_interesting_parents(struct commit *commit)
@ -265,7 +269,7 @@ static struct commit_list *do_find_bisection(struct commit_list *list,
struct commit *commit = p->item;
unsigned flags = commit->object.flags;
p->item->util = &weights[n++];
*commit_weight_at(&commit_weight, p->item) = &weights[n++];
switch (count_interesting_parents(commit)) {
case 0:
if (!(flags & TREESAME)) {
@ -372,6 +376,7 @@ void find_bisection(struct commit_list **commit_list, int *reaches,
int *weights;
show_list("bisection 2 entry", 0, 0, *commit_list);
init_commit_weight(&commit_weight);
/*
* Count the number of total and tree-changing items on the
@ -412,6 +417,7 @@ void find_bisection(struct commit_list **commit_list, int *reaches,
}
free(weights);
*commit_list = best;
clear_commit_weight(&commit_weight);
}
static int register_ref(const char *refname, const struct object_id *oid,