From 05bd4547d0d82735c3c85520a0618e5a17507710 Mon Sep 17 00:00:00 2001 From: Demi Marie Obenour Date: Mon, 21 Jul 2025 16:49:12 -0400 Subject: [PATCH] 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. --- spa/include/spa/pod/parser.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spa/include/spa/pod/parser.h b/spa/include/spa/pod/parser.h index bab03092a..a76f2fef4 100644 --- a/spa/include/spa/pod/parser.h +++ b/spa/include/spa/pod/parser.h @@ -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); }