@@ -189,7 +189,7 @@ static int count_interesting_parents(struct commit *commit)
189189 return count ;
190190}
191191
192- static inline int halfway (struct commit_list * p , int distance , int nr )
192+ static inline int halfway (struct commit_list * p , int nr )
193193{
194194 /*
195195 * 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)
202202 * 2 and 3 are halfway of 5.
203203 * 3 is halfway of 6 but 2 and 4 are not.
204204 */
205- distance *= 2 ;
206- switch (distance - nr ) {
205+ switch (2 * weight (p ) - nr ) {
207206 case -1 : case 0 : case 1 :
208207 return 1 ;
209208 default :
@@ -295,7 +294,7 @@ static struct commit_list *best_bisection(struct commit_list *list, int nr)
295294static struct commit_list * do_find_bisection (struct commit_list * list ,
296295 int nr , int * weights )
297296{
298- int n , counted , distance ;
297+ int n , counted ;
299298 struct commit_list * p ;
300299
301300 counted = 0 ;
@@ -346,15 +345,13 @@ static struct commit_list *do_find_bisection(struct commit_list *list,
346345 for (p = list ; p ; p = p -> next ) {
347346 if (p -> item -> object .flags & UNINTERESTING )
348347 continue ;
349- n = weight (p );
350- if (n != -2 )
348+ if (weight (p ) != -2 )
351349 continue ;
352- distance = count_distance (p );
350+ weight_set ( p , count_distance (p ) );
353351 clear_distance (list );
354- weight_set (p , distance );
355352
356353 /* Does it happen to be at exactly half-way? */
357- if (halfway (p , distance , nr ))
354+ if (halfway (p , nr ))
358355 return p ;
359356 counted ++ ;
360357 }
@@ -392,8 +389,7 @@ static struct commit_list *do_find_bisection(struct commit_list *list,
392389 weight_set (p , weight (q ));
393390
394391 /* Does it happen to be at exactly half-way? */
395- distance = weight (p );
396- if (halfway (p , distance , nr ))
392+ if (halfway (p , nr ))
397393 return p ;
398394 }
399395 }
0 commit comments