1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-27 17:42:17 +00:00

command: simplify option property init

The "if (prop.name)" check is redundant, because an assert above it
implies that it never can be NULL.

Deduplicate some code for initializing the "prop" variable.
This commit is contained in:
wm4 2018-05-01 03:51:14 +02:00 committed by Jan Ekström
parent 88498bcc92
commit 78fe41f246

View File

@ -6083,33 +6083,24 @@ void command_init(struct MPContext *mpctx)
if (co->opt->flags & M_OPT_NOPROP)
continue;
struct m_property prop = {0};
struct m_property prop = {
.name = co->name,
.call = mp_property_generic_option,
.is_option = true,
};
if (co->opt->type == &m_option_type_alias) {
const char *alias = (const char *)co->opt->priv;
prop.priv = co->opt->priv;
prop = (struct m_property){
.name = co->name,
.call = co->opt->deprecation_message ?
mp_property_deprecated_alias : mp_property_alias,
.priv = (void *)alias,
.is_option = true,
};
} else {
prop = (struct m_property){
.name = co->name,
.call = mp_property_generic_option,
.is_option = true,
};
prop.call = co->opt->deprecation_message ?
mp_property_deprecated_alias : mp_property_alias;
}
if (prop.name) {
// The option might be covered by a manual property already.
if (m_property_list_find(ctx->properties, prop.name))
continue;
// The option might be covered by a manual property already.
if (m_property_list_find(ctx->properties, prop.name))
continue;
ctx->properties[count++] = prop;
}
ctx->properties[count++] = prop;
}
}