summaryrefslogtreecommitdiff
path: root/string-list.c
diff options
context:
space:
mode:
authorStephen Boyd <bebarino@gmail.com>2010-03-24 00:16:02 -0700
committerJunio C Hamano <gitster@pobox.com>2010-03-24 19:41:19 -0700
commite242148012196772e3fe2652d538fb923b91ca92 (patch)
tree076db390dad5ad0e11c705debb811df32a82683c /string-list.c
parent15cb500786c3bc618dafa3c6bc9535236e7bfdcd (diff)
downloadgit-e242148012196772e3fe2652d538fb923b91ca92.tar.gz
string-list: add unsorted_string_list_lookup()
Sometimes users need to lookup a string in an unsorted string_list. In that case they should use this function instead of the version for sorted strings. Signed-off-by: Stephen Boyd <bebarino@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'string-list.c')
-rw-r--r--string-list.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/string-list.c b/string-list.c
index 1ac536e638..c9ad7fcd49 100644
--- a/string-list.c
+++ b/string-list.c
@@ -168,12 +168,19 @@ void sort_string_list(struct string_list *list)
qsort(list->items, list->nr, sizeof(*list->items), cmp_items);
}
-int unsorted_string_list_has_string(struct string_list *list, const char *string)
+struct string_list_item *unsorted_string_list_lookup(struct string_list *list,
+ const char *string)
{
int i;
for (i = 0; i < list->nr; i++)
if (!strcmp(string, list->items[i].string))
- return 1;
- return 0;
+ return list->items + i;
+ return NULL;
+}
+
+int unsorted_string_list_has_string(struct string_list *list,
+ const char *string)
+{
+ return unsorted_string_list_lookup(list, string) != NULL;
}