string_list: use string-list API in unsorted_string_list_lookup()

Using the string-list API in function unsorted_string_list_lookup()
makes the code more readable.

Signed-off-by: Ralf Thielow <ralf.thielow@gmail.com>
Acked-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Ralf Thielow 2016-04-25 19:40:00 +02:00 committed by Junio C Hamano
parent 6a6636270f
commit d16df0c062

View File

@ -231,12 +231,12 @@ void string_list_sort(struct string_list *list)
struct string_list_item *unsorted_string_list_lookup(struct string_list *list,
const char *string)
{
int i;
struct string_list_item *item;
compare_strings_fn cmp = list->cmp ? list->cmp : strcmp;
for (i = 0; i < list->nr; i++)
if (!cmp(string, list->items[i].string))
return list->items + i;
for_each_string_list_item(item, list)
if (!cmp(string, item->string))
return item;
return NULL;
}