diff options
| author | shejialuo <shejialuo@gmail.com> | 2025-10-06 14:32:40 +0800 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2025-10-06 09:11:07 -0700 |
| commit | 51c3385e3736aeb5f78cc9ed193779e2cb4a2a29 (patch) | |
| tree | 7fa12176e859434789d45fc3f4bee59e1b8ad8a8 /string-list.h | |
| parent | string-list: replace negative index encoding with "exact_match" parameter (diff) | |
| download | git-51c3385e3736aeb5f78cc9ed193779e2cb4a2a29.tar.gz git-51c3385e3736aeb5f78cc9ed193779e2cb4a2a29.zip | |
string-list: change "string_list_find_insert_index" return type to "size_t"
As "string_list_find_insert_index" is a simple wrapper of
"get_entry_index" and the return type of "get_entry_index" is already
"size_t", we could simply change its return type to "size_t".
Update all callers to use size_t variables for storing the return value.
The tricky fix is the loop condition in "mailmap.c" to properly handle
"size_t" underflow by changing from `0 <= --i` to `i--`.
Remove "DISABLE_SIGN_COMPARE_WARNINGS" from "mailmap.c" as it's no
longer needed with the proper unsigned types.
Signed-off-by: shejialuo <shejialuo@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'string-list.h')
| -rw-r--r-- | string-list.h | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/string-list.h b/string-list.h index 8830ce671d..fa6ba07853 100644 --- a/string-list.h +++ b/string-list.h @@ -173,8 +173,14 @@ void string_list_remove_empty_items(struct string_list *list, int free_util); /** Determine if the string_list has a given string or not. */ bool string_list_has_string(const struct string_list *list, const char *string); -int string_list_find_insert_index(const struct string_list *list, const char *string, - bool *exact_match); + +/** + * Find the index at which a new element should be inserted into the + * string_list to maintain sorted order. If exact_match is not NULL, + * it will be set to true if the string already exists in the list. + */ +size_t string_list_find_insert_index(const struct string_list *list, const char *string, + bool *exact_match); /** * Insert a new element to the string_list. The returned pointer can |
