MCPcopy Index your code
hub / github.com/git/git / get_entry_index

Function get_entry_index

string-list.c:18–41  ·  view source on GitHub ↗

if there is no exact match, point to the index where the entry could be * inserted */

Source from the content-addressed store, hash-verified

16/* if there is no exact match, point to the index where the entry could be
17 * inserted */
18static size_t get_entry_index(const struct string_list *list, const char *string,
19 bool *exact_match)
20{
21 size_t left = 0, right = list->nr;
22 compare_strings_fn cmp = list->cmp ? list->cmp : strcmp;
23
24 while (left < right) {
25 size_t middle = left + (right - left) / 2;
26 int compare = cmp(string, list->items[middle].string);
27 if (compare < 0)
28 right = middle;
29 else if (compare > 0)
30 left = middle + 1;
31 else {
32 if (exact_match)
33 *exact_match = true;
34 return middle;
35 }
36 }
37
38 if (exact_match)
39 *exact_match = false;
40 return right;
41}
42
43static size_t add_entry(struct string_list *list, const char *string)
44{

Callers 5

add_entryFunction · 0.85
string_list_removeFunction · 0.85
string_list_has_stringFunction · 0.85
string_list_lookupFunction · 0.85

Calls 1

cmpFunction · 0.85

Tested by

no test coverage detected