summaryrefslogtreecommitdiff
path: root/string-list.c
diff options
context:
space:
mode:
authorRalf Thielow <ralf.thielow@gmail.com>2016-04-25 19:40:00 +0200
committerJunio C Hamano <gitster@pobox.com>2016-04-25 11:48:27 -0700
commitd16df0c062e45cbaf42b99963d90c77a0ec9b7df (patch)
tree64cb746fc8bdc7c6e84d9ed81945f6f16b9055f4 /string-list.c
parent6a6636270fbaf74609cd3e1bd207dd2c420d640a (diff)
downloadgit-d16df0c062e45cbaf42b99963d90c77a0ec9b7df.tar.gz
string_list: use string-list API in unsorted_string_list_lookup()rt/string-list-lookup-cleanup
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>
Diffstat (limited to 'string-list.c')
-rw-r--r--string-list.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/string-list.c b/string-list.c
index 2a32a3f1f5..62d20846cb 100644
--- a/string-list.c
+++ b/string-list.c
@@ -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;
}