Skip to content

Commit bb408ac

Browse files
pcloudsgitster
authored andcommitted
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 <[email protected]>
1 parent 87be252 commit bb408ac

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

bisect.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "bisect.h"
1313
#include "sha1-array.h"
1414
#include "argv-array.h"
15+
#include "commit-slab.h"
1516

1617
static struct oid_array good_revs;
1718
static struct oid_array skipped_revs;
@@ -70,16 +71,19 @@ static void clear_distance(struct commit_list *list)
7071
}
7172
}
7273

74+
define_commit_slab(commit_weight, int *);
75+
static struct commit_weight commit_weight;
76+
7377
#define DEBUG_BISECT 0
7478

7579
static inline int weight(struct commit_list *elem)
7680
{
77-
return *((int*)(elem->item->util));
81+
return **commit_weight_at(&commit_weight, elem->item);
7882
}
7983

8084
static inline void weight_set(struct commit_list *elem, int weight)
8185
{
82-
*((int*)(elem->item->util)) = weight;
86+
**commit_weight_at(&commit_weight, elem->item) = weight;
8387
}
8488

8589
static int count_interesting_parents(struct commit *commit)
@@ -265,7 +269,7 @@ static struct commit_list *do_find_bisection(struct commit_list *list,
265269
struct commit *commit = p->item;
266270
unsigned flags = commit->object.flags;
267271

268-
p->item->util = &weights[n++];
272+
*commit_weight_at(&commit_weight, p->item) = &weights[n++];
269273
switch (count_interesting_parents(commit)) {
270274
case 0:
271275
if (!(flags & TREESAME)) {
@@ -372,6 +376,7 @@ void find_bisection(struct commit_list **commit_list, int *reaches,
372376
int *weights;
373377

374378
show_list("bisection 2 entry", 0, 0, *commit_list);
379+
init_commit_weight(&commit_weight);
375380

376381
/*
377382
* 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,
412417
}
413418
free(weights);
414419
*commit_list = best;
420+
clear_commit_weight(&commit_weight);
415421
}
416422

417423
static int register_ref(const char *refname, const struct object_id *oid,

0 commit comments

Comments
 (0)