sequencer: use trailer's trailer layout
[gitweb.git] / string-list.c
index 2f69c32a8abdc2e1490ff1bf5948a8ec2260150c..8c83cac189e94c327327e47cfaadfd621d59b6b9 100644 (file)
@@ -59,13 +59,7 @@ static int add_entry(int insert_at, struct string_list *list, const char *string
 
 struct string_list_item *string_list_insert(struct string_list *list, const char *string)
 {
-       return string_list_insert_at_index(list, -1, string);
-}
-
-struct string_list_item *string_list_insert_at_index(struct string_list *list,
-                                                    int insert_at, const char *string)
-{
-       int index = add_entry(insert_at, list, string);
+       int index = add_entry(-1, list, string);
 
        if (index < 0)
                index = -1 - index;
@@ -231,18 +225,18 @@ static int cmp_items(const void *a, const void *b)
 void string_list_sort(struct string_list *list)
 {
        compare_for_qsort = list->cmp ? list->cmp : strcmp;
-       qsort(list->items, list->nr, sizeof(*list->items), cmp_items);
+       QSORT(list->items, list->nr, cmp_items);
 }
 
 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;
 }