pod: move common check outside of the loop

This commit is contained in:
Wim Taymans 2025-04-15 18:33:29 +02:00
parent 4774178c68
commit d1d580cafa

View file

@ -209,10 +209,9 @@ spa_pod_filter_prop(struct spa_pod_builder *b,
bool found_def = false; bool found_def = false;
/* we should prefer the alt2 range default value but only if valid */ /* we should prefer the alt2 range default value but only if valid */
if (spa_pod_compare_value(type, alt2, min, size) >= 0 &&
spa_pod_compare_value(type, alt2, max, size) <= 0) {
for (j = 0, a1 = alt1; j < nalt1; j++, a1 = SPA_PTROFF(a1,size,void)) { for (j = 0, a1 = alt1; j < nalt1; j++, a1 = SPA_PTROFF(a1,size,void)) {
if (spa_pod_compare_value(type, alt2, min, size) < 0 ||
spa_pod_compare_value(type, alt2, max, size) > 0)
break;
if (spa_pod_compare_value(type, a1, alt2, size) == 0) { if (spa_pod_compare_value(type, a1, alt2, size) == 0) {
/* it is in the enum, use as default then */ /* it is in the enum, use as default then */
spa_pod_builder_raw(b, a1, size); spa_pod_builder_raw(b, a1, size);
@ -220,6 +219,7 @@ spa_pod_filter_prop(struct spa_pod_builder *b,
break; break;
} }
} }
}
/* copy all values inside the range */ /* copy all values inside the range */
for (j = 0, a1 = alt1; j < nalt1; j++, a1 = SPA_PTROFF(a1,size,void)) { for (j = 0, a1 = alt1; j < nalt1; j++, a1 = SPA_PTROFF(a1,size,void)) {
if ((res = spa_pod_filter_is_in_range(type, a1, min, max, step, size)) < 0) if ((res = spa_pod_filter_is_in_range(type, a1, min, max, step, size)) < 0)