rev-list --bisect: Bisection "distance" clean up.
Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Christian Couder committed
Sep 17, 2007 at 05:28 UTC
53271411e7c4d9b92cc5aa1cc02492e9a3593d23
1 file changed
+7
-11
builtin-rev-list.c
+7
-11
@@ -189,7 +189,7 @@ static int count_interesting_parents(struct commit *commit)
189
return count;
190
}
191
192
-static inline int halfway(struct commit_list *p, int distance, int nr)
192
+static inline int halfway(struct commit_list *p, int nr)
193
{
194
/*
195
* Don't short-cut something we are not going to return!
@@ -202,8 +202,7 @@ static inline int halfway(struct commit_list *p, int distance, int nr)
202
* 2 and 3 are halfway of 5.
203
* 3 is halfway of 6 but 2 and 4 are not.
204
*/
205
- distance *= 2;
206
- switch (distance - nr) {
205
+ switch (2 * weight(p) - nr) {
206
case -1: case 0: case 1:
207
return 1;
208
default:
@@ -295,7 +294,7 @@ static struct commit_list *best_bisection(struct commit_list *list, int nr)
294
static struct commit_list *do_find_bisection(struct commit_list *list,
295
int nr, int *weights)
296
{
298
- int n, counted, distance;
297
+ int n, counted;
298
struct commit_list *p;
299
300
counted = 0;
@@ -346,15 +345,13 @@ static struct commit_list *do_find_bisection(struct commit_list *list,
345
for (p = list; p; p = p->next) {
346
if (p->item->object.flags & UNINTERESTING)
347
continue;
349
- n = weight(p);
350
- if (n != -2)
348
+ if (weight(p) != -2)
349
continue;
352
- distance = count_distance(p);
350
+ weight_set(p, count_distance(p));
351
clear_distance(list);
354
- weight_set(p, distance);
352
353
/* Does it happen to be at exactly half-way? */
357
- if (halfway(p, distance, nr))
354
+ if (halfway(p, nr))
355
return p;
356
counted++;
357
}
@@ -392,8 +389,7 @@ static struct commit_list *do_find_bisection(struct commit_list *list,
389
weight_set(p, weight(q));
390
391
/* Does it happen to be at exactly half-way? */
395
- distance = weight(p);
396
- if (halfway(p, distance, nr))
392
+ if (halfway(p, nr))
393
return p;
394
}
395
}