summaryrefslogtreecommitdiff
path: root/string-list.c
diff options
context:
space:
mode:
authorRalf Thielow <ralf.thielow@gmail.com>2016-04-25 17:40:00 (GMT)
committerJunio C Hamano <gitster@pobox.com>2016-04-25 18:48:27 (GMT)
commitd16df0c062e45cbaf42b99963d90c77a0ec9b7df (patch)
tree64cb746fc8bdc7c6e84d9ed81945f6f16b9055f4 /string-list.c
parent6a6636270fbaf74609cd3e1bd207dd2c420d640a (diff)
downloadgit-d16df0c062e45cbaf42b99963d90c77a0ec9b7df.zip
git-d16df0c062e45cbaf42b99963d90c77a0ec9b7df.tar.gz
git-d16df0c062e45cbaf42b99963d90c77a0ec9b7df.tar.bz2
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>
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 2a32a3f..62d2084 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;
}