Skip to content

Commit 4b8cb2c

Browse files
committed
Merge branch 'nd/qsort-in-merge-recursive' into pu
Code simplification. * nd/qsort-in-merge-recursive: merge-recursive.c: use string_list_sort instead of qsort
2 parents fd7d54c + fa6ca11 commit 4b8cb2c

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

merge-recursive.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -389,12 +389,10 @@ static struct string_list *get_unmerged(void)
389389
return unmerged;
390390
}
391391

392-
static int string_list_df_name_compare(const void *a, const void *b)
392+
static int string_list_df_name_compare(const char *one, const char *two)
393393
{
394-
const struct string_list_item *one = a;
395-
const struct string_list_item *two = b;
396-
int onelen = strlen(one->string);
397-
int twolen = strlen(two->string);
394+
int onelen = strlen(one);
395+
int twolen = strlen(two);
398396
/*
399397
* Here we only care that entries for D/F conflicts are
400398
* adjacent, in particular with the file of the D/F conflict
@@ -407,8 +405,8 @@ static int string_list_df_name_compare(const void *a, const void *b)
407405
* since in other cases any changes in their order due to
408406
* sorting cause no problems for us.
409407
*/
410-
int cmp = df_name_compare(one->string, onelen, S_IFDIR,
411-
two->string, twolen, S_IFDIR);
408+
int cmp = df_name_compare(one, onelen, S_IFDIR,
409+
two, twolen, S_IFDIR);
412410
/*
413411
* Now that 'foo' and 'foo/bar' compare equal, we have to make sure
414412
* that 'foo' comes before 'foo/bar'.
@@ -452,8 +450,8 @@ static void record_df_conflict_files(struct merge_options *o,
452450
string_list_append(&df_sorted_entries, next->string)->util =
453451
next->util;
454452
}
455-
qsort(df_sorted_entries.items, entries->nr, sizeof(*entries->items),
456-
string_list_df_name_compare);
453+
df_sorted_entries.cmp = string_list_df_name_compare;
454+
string_list_sort(&df_sorted_entries);
457455

458456
string_list_clear(&o->df_conflict_file_set, 1);
459457
for (i = 0; i < df_sorted_entries.nr; i++) {

0 commit comments

Comments
 (0)