clean up some more array iterations

This commit is contained in:
Wim Taymans 2022-09-30 17:23:05 +02:00
parent 0b98614bea
commit 9b6e504c19
14 changed files with 88 additions and 114 deletions

View file

@ -345,11 +345,10 @@ static const struct msg_info msg_info[] = {
static inline const struct msg_info *find_msg_info(uint16_t type, const char *name)
{
uint32_t i;
for (i = 0; i < SPA_N_ELEMENTS(msg_info); i++) {
if ((name == NULL && type == msg_info[i].type) ||
(name != NULL && spa_streq(name, msg_info[i].name)))
return &msg_info[i];
SPA_FOR_EACH_ELEMENT_VAR(msg_info, i) {
if ((name == NULL && type == i->type) ||
(name != NULL && spa_streq(name, i->name)))
return i;
}
return NULL;
}

View file

@ -250,11 +250,10 @@ static const struct cmd_info cmd_info[] = {
static inline const struct cmd_info *find_cmd_info(uint16_t type, const char *name)
{
uint32_t i;
for (i = 0; i < SPA_N_ELEMENTS(cmd_info); i++) {
if ((name == NULL && type == cmd_info[i].type) ||
(name != NULL && spa_streq(name, cmd_info[i].name)))
return &cmd_info[i];
SPA_FOR_EACH_ELEMENT_VAR(cmd_info, i) {
if ((name == NULL && type == i->type) ||
(name != NULL && spa_streq(name, i->name)))
return i;
}
return NULL;
}

View file

@ -67,11 +67,10 @@ static const struct msg_info msg_info[] = {
static inline const struct msg_info *find_msg_info(uint16_t type, const char *name)
{
uint32_t i;
for (i = 0; i < SPA_N_ELEMENTS(msg_info); i++) {
if ((name == NULL && type == msg_info[i].type) ||
(name != NULL && spa_streq(name, msg_info[i].name)))
return &msg_info[i];
SPA_FOR_EACH_ELEMENT_VAR(msg_info, i) {
if ((name == NULL && type == i->type) ||
(name != NULL && spa_streq(name, i->name)))
return i;
}
return NULL;
}