blame: wrap blame_sort and compare_blame_final
The new method's interface is marginally cleaner than blame_sort, and will avoid the need to expose the compare_blame_final method. Signed-off-by: Jeff Smith <whydoubt@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff Smith committed
May 24, 2017 at 00:15 UTC
78b06e66be7806e7fa092c96a47be95984e7aee6
1 file changed
+9
-8
builtin/blame.c
+9
-8
@@ -328,12 +328,6 @@ static int compare_blame_suspect(const void *p1, const void *p2)
328
return s1->s_lno > s2->s_lno ? 1 : -1;
329
}
330
331
-static struct blame_entry *blame_sort(struct blame_entry *head,
332
- int (*compare_fn)(const void *, const void *))
333
-{
334
- return llist_mergesort (head, get_next_blame, set_next_blame, compare_fn);
335
-}
336
-
331
static int compare_commits_by_reverse_commit_date(const void *a,
332
const void *b,
333
void *c)
@@ -396,6 +390,12 @@ struct blame_scoreboard {
390
void *found_guilty_entry_data;
391
};
392
393
+static void blame_sort_final(struct blame_scoreboard *sb)
394
+{
395
+ sb->ent = llist_mergesort(sb->ent, get_next_blame, set_next_blame,
396
+ compare_blame_final);
397
+}
398
+
399
static void sanity_check_refcnt(struct blame_scoreboard *);
400
401
/*
@@ -1378,7 +1378,8 @@ static int num_scapegoats(struct rev_info *revs, struct commit *commit, int reve
1378
*/
1379
static void distribute_blame(struct blame_scoreboard *sb, struct blame_entry *blamed)
1380
{
1381
- blamed = blame_sort(blamed, compare_blame_suspect);
1381
+ blamed = llist_mergesort(blamed, get_next_blame, set_next_blame,
1382
+ compare_blame_suspect);
1383
while (blamed)
1384
{
1385
struct blame_origin *porigin = blamed->suspect;
@@ -2922,7 +2923,7 @@ parse_done:
2923
if (incremental)
2924
return 0;
2925
2925
- sb.ent = blame_sort(sb.ent, compare_blame_final);
2926
+ blame_sort_final(&sb);
2927
2928
blame_coalesce(&sb);
2929