pod: parser: avoid unneeded integer division

SPA_POD_CHOICE_N_VALUES involves an integer division, which is slow.
Replace it with subtraction and comparison.

No functional change intended.
This commit is contained in:
Demi Marie Obenour 2025-07-21 16:49:12 -04:00 committed by Wim Taymans
parent da1d4fb30c
commit 05bd4547d0

View file

@ -286,7 +286,8 @@ SPA_API_POD_PARSER bool spa_pod_parser_can_collect(const struct spa_pod *pod, ch
return true;
if (SPA_POD_CHOICE_TYPE(pod) != SPA_CHOICE_None)
return false;
if (SPA_POD_CHOICE_N_VALUES(pod) < 1)
if (pod->size - sizeof(struct spa_pod_choice_body) <
SPA_POD_CHOICE_VALUE_SIZE(pod))
return false;
pod = SPA_POD_CHOICE_CHILD(pod);
}