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>
Nguyễn Thái Ngọc Duy committed
May 19, 2018 at 07:28 UTC
bb408ac95d34b26cb39f7796d66092fcc004c60c
1 file changed
+9
-3
bisect.c
+9
-3
@@ -12,6 +12,7 @@
12
#include "bisect.h"
13
#include "sha1-array.h"
14
#include "argv-array.h"
15
+#include "commit-slab.h"
16
17
static struct oid_array good_revs;
18
static struct oid_array skipped_revs;
@@ -70,16 +71,19 @@ static void clear_distance(struct commit_list *list)
71
}
72
}
73
74
+define_commit_slab(commit_weight, int *);
75
+static struct commit_weight commit_weight;
76
+
77
#define DEBUG_BISECT 0
78
79
static inline int weight(struct commit_list *elem)
80
{
77
- return *((int*)(elem->item->util));
81
+ return **commit_weight_at(&commit_weight, elem->item);
82
}
83
84
static inline void weight_set(struct commit_list *elem, int weight)
85
{
82
- *((int*)(elem->item->util)) = weight;
86
+ **commit_weight_at(&commit_weight, elem->item) = weight;
87
}
88
89
static int count_interesting_parents(struct commit *commit)
@@ -265,7 +269,7 @@ static struct commit_list *do_find_bisection(struct commit_list *list,
269
struct commit *commit = p->item;
270
unsigned flags = commit->object.flags;
271
268
- p->item->util = &weights[n++];
272
+ *commit_weight_at(&commit_weight, p->item) = &weights[n++];
273
switch (count_interesting_parents(commit)) {
274
case 0:
275
if (!(flags & TREESAME)) {
@@ -372,6 +376,7 @@ void find_bisection(struct commit_list **commit_list, int *reaches,
376
int *weights;
377
378
show_list("bisection 2 entry", 0, 0, *commit_list);
379
+ init_commit_weight(&commit_weight);
380
381
/*
382
* 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,
417
}
418
free(weights);
419
*commit_list = best;
420
+ clear_commit_weight(&commit_weight);
421
}
422
423
static int register_ref(const char *refname, const struct object_id *oid,