From 2e711acfbdfc0fedf631688d78cde153ba835c93 Mon Sep 17 00:00:00 2001 From: Amisha Chhajed Date: Thu, 29 Jan 2026 17:42:20 +0530 Subject: string-list: add string_list_sort_u() that mimics "sort -u" Many callsites of string_list_remove_duplicates() call it immdediately after calling string_list_sort(), understandably as the former requires string-list to be sorted, it is clear that these places are sorting only to remove duplicates and for no other reason. Introduce a helper function string_list_sort_u that combines these two calls that often appear together, to simplify these callsites. Replace the current calls of those methods with string_list_sort_u(). Signed-off-by: Amisha Chhajed Signed-off-by: Junio C Hamano --- string-list.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'string-list.c') diff --git a/string-list.c b/string-list.c index 08dc00984c..020ed8fef7 100644 --- a/string-list.c +++ b/string-list.c @@ -247,6 +247,12 @@ void string_list_sort(struct string_list *list) QSORT_S(list->items, list->nr, cmp_items, &sort_ctx); } +void string_list_sort_u(struct string_list *list, int free_util) +{ + string_list_sort(list); + string_list_remove_duplicates(list, free_util); +} + struct string_list_item *unsorted_string_list_lookup(struct string_list *list, const char *string) { -- cgit v1.3