glib-aux: use nm_streq() in _nm_strv_find_first() instead of strcmp()

nm_streq() is better for readability. Prefer it over strcmp(). Note that
nm_streq() will be inlined, so it should make no difference performance
wise.

While at it, drop wrong comment.
This commit is contained in:
Thomas Haller 2023-10-16 15:00:01 +02:00
parent 94ead251de
commit de5ba4c605
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

@ -1964,8 +1964,6 @@ nm_utils_strsplit_quoted(const char *str)
* Searches @list for @needle and returns the index of the first match (based
* on strcmp()).
*
* For convenience, @list has type 'char**' instead of 'const char **'.
*
* Returns: index of first occurrence or -1 if @needle is not found in @list.
*/
gssize
@ -1984,7 +1982,7 @@ _nm_strv_find_first(const char *const *list, gssize len, const char *needle)
}
} else {
for (i = 0; i < len; i++) {
if (list[i] && !strcmp(needle, list[i]))
if (list[i] && nm_streq(needle, list[i]))
return i;
}
}
@ -1993,7 +1991,7 @@ _nm_strv_find_first(const char *const *list, gssize len, const char *needle)
if (list) {
for (i = 0; list[i]; i++) {
if (strcmp(needle, list[i]) == 0)
if (nm_streq(needle, list[i]))
return i;
}
}