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

@ -130,25 +130,22 @@ static struct {
static inline uint32_t sdl_format_to_id(Uint32 format)
{
size_t i;
for (i = 0; i < SPA_N_ELEMENTS(sdl_video_formats); i++) {
if (sdl_video_formats[i].format == format)
return sdl_video_formats[i].id;
SPA_FOR_EACH_ELEMENT_VAR(sdl_video_formats, f) {
if (f->format == format)
return f->id;
}
return SPA_VIDEO_FORMAT_UNKNOWN;
}
static inline Uint32 id_to_sdl_format(uint32_t id)
{
size_t i;
for (i = 0; i < SPA_N_ELEMENTS(sdl_video_formats); i++) {
if (sdl_video_formats[i].id == id)
return sdl_video_formats[i].format;
SPA_FOR_EACH_ELEMENT_VAR(sdl_video_formats, f) {
if (f->id == id)
return f->format;
}
return SDL_PIXELFORMAT_UNKNOWN;
}
static inline struct spa_pod *sdl_build_formats(SDL_RendererInfo *info, struct spa_pod_builder *b)
{
uint32_t i, c;
@ -178,8 +175,8 @@ static inline struct spa_pod *sdl_build_formats(SDL_RendererInfo *info, struct s
spa_pod_builder_id(b, id);
}
/* then all the other ones SDL can convert from/to */
for (i = 0; i < SPA_N_ELEMENTS(sdl_video_formats); i++) {
uint32_t id = sdl_video_formats[i].id;
SPA_FOR_EACH_ELEMENT_VAR(sdl_video_formats, f) {
uint32_t id = f->id;
if (id != SPA_VIDEO_FORMAT_UNKNOWN)
spa_pod_builder_id(b, id);
}